Migrated portfolio to be linked to the organisation
This commit is contained in:
@@ -9,12 +9,19 @@ public sealed class Portfolio : IEntityTypeConfiguration<Domain.Entities.Portfol
|
||||
builder.ToTable(nameof(Domain.Entities.Portfolio).Pluralize());
|
||||
|
||||
builder.HasKey(pk => pk.Id);
|
||||
builder.Property(f => f.OrganisationId).IsRequired();
|
||||
builder.Property(f => f.CreatedBy).IsRequired();
|
||||
builder.Property(f => f.OwnedBy).IsRequired();
|
||||
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
|
||||
builder.Property(f => f.Name).IsRequired().HasMaxLength(LabelLength);
|
||||
builder.Property(f => f.Description).IsRequired(false).HasMaxLength(TextLength);
|
||||
|
||||
builder.HasOne(f => f.Organisation)
|
||||
.WithMany()
|
||||
.HasForeignKey(fk => fk.OrganisationId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(f => f.Creator)
|
||||
.WithMany()
|
||||
.HasForeignKey(fk => fk.CreatedBy)
|
||||
|
||||
@@ -7,5 +7,7 @@ public class Portfolio : Models.Portfolio
|
||||
|
||||
public virtual User? Owner { get; set; }
|
||||
|
||||
public virtual Organisation? Organisation { get; set; }
|
||||
|
||||
public virtual ICollection<Programme> Programmes { get; set; } = [];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ public class Portfolio
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public long OrganisationId { get; set; }
|
||||
|
||||
public Guid OwnedBy { get; set; }
|
||||
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
+1979
File diff suppressed because it is too large
Load Diff
+50
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -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");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user