Migrated portfolio to be linked to the organisation

This commit is contained in:
2026-09-05 10:57:10 +02:00
parent a218b19875
commit e274c33592
6 changed files with 2053 additions and 0 deletions
@@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PostFundManagement.Infrastructure.Database.Migrations
{
/// <inheritdoc />
public partial class AddedOrganisationToPortfolio : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "OrganisationId",
table: "Portfolios",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.CreateIndex(
name: "IX_Portfolios_OrganisationId",
table: "Portfolios",
column: "OrganisationId");
migrationBuilder.AddForeignKey(
name: "FK_Portfolios_Organisations_OrganisationId",
table: "Portfolios",
column: "OrganisationId",
principalTable: "Organisations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Portfolios_Organisations_OrganisationId",
table: "Portfolios");
migrationBuilder.DropIndex(
name: "IX_Portfolios_OrganisationId",
table: "Portfolios");
migrationBuilder.DropColumn(
name: "OrganisationId",
table: "Portfolios");
}
}
}
@@ -1006,6 +1006,9 @@ namespace PostFundManagement.Infrastructure.Database.Migrations
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<long>("OrganisationId")
.HasColumnType("bigint");
b.Property<Guid>("OwnedBy")
.HasColumnType("uuid");
@@ -1013,6 +1016,8 @@ namespace PostFundManagement.Infrastructure.Database.Migrations
b.HasIndex("CreatedBy");
b.HasIndex("OrganisationId");
b.HasIndex("OwnedBy");
b.ToTable("Portfolios", (string)null);
@@ -1799,6 +1804,12 @@ namespace PostFundManagement.Infrastructure.Database.Migrations
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.HasOne("PostFundManagement.Domain.Entities.Organisation", "Organisation")
.WithMany()
.HasForeignKey("OrganisationId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("PostFundManagement.Domain.Entities.User", "Owner")
.WithMany()
.HasForeignKey("OwnedBy")
@@ -1807,6 +1818,8 @@ namespace PostFundManagement.Infrastructure.Database.Migrations
b.Navigation("Creator");
b.Navigation("Organisation");
b.Navigation("Owner");
});