using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace PostFundManagement.Infrastructure.Database.Migrations { /// public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "uuid", nullable: false), LastLoginAt = table.Column(type: "timestamp with time zone", nullable: true), Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "2") }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "AuditLogs", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), EntityName = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), EntityId = table.Column(type: "bigint", nullable: false), Action = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), Changes = table.Column(type: "jsonb", nullable: true), PerformedBy = table.Column(type: "uuid", nullable: false), Timestamp = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()") }, constraints: table => { table.PrimaryKey("PK_AuditLogs", x => x.Id); table.ForeignKey( name: "FK_AuditLogs_Users_PerformedBy", column: x => x.PerformedBy, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Instruments", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Description = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: true), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "2"), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()") }, constraints: table => { table.PrimaryKey("PK_Instruments", x => x.Id); table.ForeignKey( name: "FK_Instruments_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Organisations", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), RegistrationNo = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Type = table.Column(type: "integer", nullable: false, defaultValueSql: "5"), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1") }, constraints: table => { table.PrimaryKey("PK_Organisations", x => x.Id); table.ForeignKey( name: "FK_Organisations_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Portfolios", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), OwnedBy = table.Column(type: "uuid", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Description = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Portfolios", x => x.Id); table.ForeignKey( name: "FK_Portfolios_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Portfolios_Users_OwnedBy", column: x => x.OwnedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Programmes", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), PortfolioId = table.Column(type: "bigint", nullable: false), InstrumentId = table.Column(type: "bigint", nullable: false), OwnedBy = table.Column(type: "uuid", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1") }, constraints: table => { table.PrimaryKey("PK_Programmes", x => x.Id); table.ForeignKey( name: "FK_Programmes_Instruments_InstrumentId", column: x => x.InstrumentId, principalTable: "Instruments", principalColumn: "Id"); table.ForeignKey( name: "FK_Programmes_Portfolios_PortfolioId", column: x => x.PortfolioId, principalTable: "Portfolios", principalColumn: "Id"); table.ForeignKey( name: "FK_Programmes_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Programmes_Users_OwnedBy", column: x => x.OwnedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Projects", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProgrammeId = table.Column(type: "bigint", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), StartedAt = table.Column(type: "timestamp with time zone", nullable: true), EndedAt = table.Column(type: "timestamp with time zone", nullable: true), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Description = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1") }, constraints: table => { table.PrimaryKey("PK_Projects", x => x.Id); table.ForeignKey( name: "FK_Projects_Programmes_ProgrammeId", column: x => x.ProgrammeId, principalTable: "Programmes", principalColumn: "Id"); table.ForeignKey( name: "FK_Projects_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Projects_Users_UpdatedBy", column: x => x.UpdatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Rules", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProgrammeId = table.Column(type: "bigint", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Version = table.Column(type: "integer", nullable: false, defaultValue: 1), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "2") }, constraints: table => { table.PrimaryKey("PK_Rules", x => x.Id); table.ForeignKey( name: "FK_Rules_Programmes_ProgrammeId", column: x => x.ProgrammeId, principalTable: "Programmes", principalColumn: "Id"); table.ForeignKey( name: "FK_Rules_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Rules_Users_UpdatedBy", column: x => x.UpdatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Awards", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), OrganisationId = table.Column(type: "bigint", nullable: false), ProgrammeId = table.Column(type: "bigint", nullable: false), ProjectId = table.Column(type: "bigint", nullable: true), CreatedBy = table.Column(type: "uuid", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: true), ApprovedBy = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1"), Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Awards", x => x.Id); table.ForeignKey( name: "FK_Awards_Organisations_OrganisationId", column: x => x.OrganisationId, principalTable: "Organisations", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Awards_Programmes_ProgrammeId", column: x => x.ProgrammeId, principalTable: "Programmes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Awards_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_Awards_Users_ApprovedBy", column: x => x.ApprovedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Awards_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Awards_Users_UpdatedBy", column: x => x.UpdatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Beneficiaries", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), UserId = table.Column(type: "uuid", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Category = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), TargetCount = table.Column(type: "integer", nullable: false), ReachedCount = table.Column(type: "integer", nullable: false), Location = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Beneficiaries", x => x.Id); table.ForeignKey( name: "FK_Beneficiaries_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Beneficiaries_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Beneficiaries_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Budgets", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), ApprovedBy = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Budgets", x => x.Id); table.ForeignKey( name: "FK_Budgets_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Budgets_Users_ApprovedBy", column: x => x.ApprovedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Budgets_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "ChangeRequests", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), Title = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Justification = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), RevisedBudget = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true), RevisedEndedAt = table.Column(type: "timestamp with time zone", nullable: true), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1"), CreatedBy = table.Column(type: "uuid", nullable: false), ApprovedBy = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ChangeRequests", x => x.Id); table.ForeignKey( name: "FK_ChangeRequests_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ChangeRequests_Users_ApprovedBy", column: x => x.ApprovedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_ChangeRequests_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "ComplianceItems", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), Title = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Requirements = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: false), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1"), CreatedBy = table.Column(type: "uuid", nullable: false), VerifiedBy = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ComplianceItems", x => x.Id); table.ForeignKey( name: "FK_ComplianceItems_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ComplianceItems_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_ComplianceItems_Users_VerifiedBy", column: x => x.VerifiedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Indicators", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), UnitOfMeasure = table.Column(type: "integer", nullable: false, defaultValueSql: "2"), BaselineAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), TargetAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), ActualAmount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Indicators", x => x.Id); table.ForeignKey( name: "FK_Indicators_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Indicators_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Issues", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), Title = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Description = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), Priority = table.Column(type: "integer", nullable: false, defaultValueSql: "1"), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1"), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), ResolvedAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Issues", x => x.Id); table.ForeignKey( name: "FK_Issues_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Issues_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Milestones", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), DueAt = table.Column(type: "timestamp with time zone", nullable: false), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1") }, constraints: table => { table.PrimaryKey("PK_Milestones", x => x.Id); table.ForeignKey( name: "FK_Milestones_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Milestones_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Milestones_Users_UpdatedBy", column: x => x.UpdatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Risks", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), Likelihood = table.Column(type: "integer", nullable: false, defaultValueSql: "3"), Impact = table.Column(type: "integer", nullable: false, defaultValueSql: "1"), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Description = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Risks", x => x.Id); table.ForeignKey( name: "FK_Risks_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Risks_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "SiteVisits", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), VisitedAt = table.Column(type: "timestamp with time zone", nullable: false), InspectorName = table.Column(type: "text", nullable: false), Findings = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1"), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()") }, constraints: table => { table.PrimaryKey("PK_SiteVisits", x => x.Id); table.ForeignKey( name: "FK_SiteVisits_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_SiteVisits_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Contracts", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), AwardId = table.Column(type: "bigint", nullable: false), ExternalSignatureId = table.Column(type: "text", nullable: true), SignedDocumentUrl = table.Column(type: "text", nullable: true), EffectiveAt = table.Column(type: "timestamp with time zone", nullable: true), ExpiresAt = table.Column(type: "timestamp with time zone", nullable: true), TotalValue = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1"), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()") }, constraints: table => { table.PrimaryKey("PK_Contracts", x => x.Id); table.ForeignKey( name: "FK_Contracts_Awards_AwardId", column: x => x.AwardId, principalTable: "Awards", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Contracts_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Outcomes", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), BeneficiaryId = table.Column(type: "bigint", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Description = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Outcomes", x => x.Id); table.ForeignKey( name: "FK_Outcomes_Beneficiaries_BeneficiaryId", column: x => x.BeneficiaryId, principalTable: "Beneficiaries", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Outcomes_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Disbursements", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), MilestoneId = table.Column(type: "bigint", nullable: true), CreatedBy = table.Column(type: "uuid", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), Amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1") }, constraints: table => { table.PrimaryKey("PK_Disbursements", x => x.Id); table.ForeignKey( name: "FK_Disbursements_Milestones_MilestoneId", column: x => x.MilestoneId, principalTable: "Milestones", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Disbursements_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Disbursements_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Disbursements_Users_UpdatedBy", column: x => x.UpdatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Evidences", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "bigint", nullable: false), MilestoneId = table.Column(type: "bigint", nullable: false), IndicatorId = table.Column(type: "bigint", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true), Version = table.Column(type: "integer", nullable: false, defaultValue: 1), DocumentUrl = table.Column(type: "text", nullable: false), Status = table.Column(type: "integer", nullable: false, defaultValueSql: "1") }, constraints: table => { table.PrimaryKey("PK_Evidences", x => x.Id); table.ForeignKey( name: "FK_Evidences_Indicators_IndicatorId", column: x => x.IndicatorId, principalTable: "Indicators", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Evidences_Milestones_MilestoneId", column: x => x.MilestoneId, principalTable: "Milestones", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Evidences_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Evidences_Users_CreatedBy", column: x => x.CreatedBy, principalTable: "Users", principalColumn: "Id"); table.ForeignKey( name: "FK_Evidences_Users_UpdatedBy", column: x => x.UpdatedBy, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_AuditLogs_PerformedBy", table: "AuditLogs", column: "PerformedBy"); migrationBuilder.CreateIndex( name: "IX_Awards_ApprovedBy", table: "Awards", column: "ApprovedBy"); migrationBuilder.CreateIndex( name: "IX_Awards_CreatedBy", table: "Awards", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Awards_OrganisationId", table: "Awards", column: "OrganisationId"); migrationBuilder.CreateIndex( name: "IX_Awards_ProgrammeId", table: "Awards", column: "ProgrammeId"); migrationBuilder.CreateIndex( name: "IX_Awards_ProjectId", table: "Awards", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Awards_UpdatedBy", table: "Awards", column: "UpdatedBy"); migrationBuilder.CreateIndex( name: "IX_Beneficiaries_CreatedBy", table: "Beneficiaries", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Beneficiaries_ProjectId", table: "Beneficiaries", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Beneficiaries_UserId", table: "Beneficiaries", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Budgets_ApprovedBy", table: "Budgets", column: "ApprovedBy"); migrationBuilder.CreateIndex( name: "IX_Budgets_CreatedBy", table: "Budgets", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Budgets_ProjectId", table: "Budgets", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_ChangeRequests_ApprovedBy", table: "ChangeRequests", column: "ApprovedBy"); migrationBuilder.CreateIndex( name: "IX_ChangeRequests_CreatedBy", table: "ChangeRequests", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_ChangeRequests_ProjectId", table: "ChangeRequests", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_ComplianceItems_CreatedBy", table: "ComplianceItems", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_ComplianceItems_ProjectId", table: "ComplianceItems", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_ComplianceItems_VerifiedBy", table: "ComplianceItems", column: "VerifiedBy"); migrationBuilder.CreateIndex( name: "IX_Contracts_AwardId", table: "Contracts", column: "AwardId", unique: true); migrationBuilder.CreateIndex( name: "IX_Contracts_CreatedBy", table: "Contracts", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Disbursements_CreatedBy", table: "Disbursements", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Disbursements_MilestoneId", table: "Disbursements", column: "MilestoneId"); migrationBuilder.CreateIndex( name: "IX_Disbursements_ProjectId", table: "Disbursements", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Disbursements_UpdatedBy", table: "Disbursements", column: "UpdatedBy"); migrationBuilder.CreateIndex( name: "IX_Evidences_CreatedBy", table: "Evidences", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Evidences_IndicatorId", table: "Evidences", column: "IndicatorId"); migrationBuilder.CreateIndex( name: "IX_Evidences_MilestoneId", table: "Evidences", column: "MilestoneId"); migrationBuilder.CreateIndex( name: "IX_Evidences_ProjectId", table: "Evidences", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Evidences_UpdatedBy", table: "Evidences", column: "UpdatedBy"); migrationBuilder.CreateIndex( name: "IX_Indicators_CreatedBy", table: "Indicators", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Indicators_ProjectId", table: "Indicators", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Instruments_CreatedBy", table: "Instruments", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Issues_CreatedBy", table: "Issues", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Issues_ProjectId", table: "Issues", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Milestones_CreatedBy", table: "Milestones", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Milestones_ProjectId", table: "Milestones", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Milestones_UpdatedBy", table: "Milestones", column: "UpdatedBy"); migrationBuilder.CreateIndex( name: "IX_Organisations_CreatedBy", table: "Organisations", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Outcomes_BeneficiaryId", table: "Outcomes", column: "BeneficiaryId"); migrationBuilder.CreateIndex( name: "IX_Outcomes_CreatedBy", table: "Outcomes", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Portfolios_CreatedBy", table: "Portfolios", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Portfolios_OwnedBy", table: "Portfolios", column: "OwnedBy"); migrationBuilder.CreateIndex( name: "IX_Programmes_CreatedBy", table: "Programmes", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Programmes_InstrumentId", table: "Programmes", column: "InstrumentId"); migrationBuilder.CreateIndex( name: "IX_Programmes_OwnedBy", table: "Programmes", column: "OwnedBy"); migrationBuilder.CreateIndex( name: "IX_Programmes_PortfolioId", table: "Programmes", column: "PortfolioId"); migrationBuilder.CreateIndex( name: "IX_Projects_CreatedBy", table: "Projects", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Projects_ProgrammeId", table: "Projects", column: "ProgrammeId"); migrationBuilder.CreateIndex( name: "IX_Projects_UpdatedBy", table: "Projects", column: "UpdatedBy"); migrationBuilder.CreateIndex( name: "IX_Risks_CreatedBy", table: "Risks", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Risks_ProjectId", table: "Risks", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Rules_CreatedBy", table: "Rules", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_Rules_ProgrammeId", table: "Rules", column: "ProgrammeId"); migrationBuilder.CreateIndex( name: "IX_Rules_UpdatedBy", table: "Rules", column: "UpdatedBy"); migrationBuilder.CreateIndex( name: "IX_SiteVisits_CreatedBy", table: "SiteVisits", column: "CreatedBy"); migrationBuilder.CreateIndex( name: "IX_SiteVisits_ProjectId", table: "SiteVisits", column: "ProjectId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AuditLogs"); migrationBuilder.DropTable( name: "Budgets"); migrationBuilder.DropTable( name: "ChangeRequests"); migrationBuilder.DropTable( name: "ComplianceItems"); migrationBuilder.DropTable( name: "Contracts"); migrationBuilder.DropTable( name: "Disbursements"); migrationBuilder.DropTable( name: "Evidences"); migrationBuilder.DropTable( name: "Issues"); migrationBuilder.DropTable( name: "Outcomes"); migrationBuilder.DropTable( name: "Risks"); migrationBuilder.DropTable( name: "Rules"); migrationBuilder.DropTable( name: "SiteVisits"); migrationBuilder.DropTable( name: "Awards"); migrationBuilder.DropTable( name: "Indicators"); migrationBuilder.DropTable( name: "Milestones"); migrationBuilder.DropTable( name: "Beneficiaries"); migrationBuilder.DropTable( name: "Organisations"); migrationBuilder.DropTable( name: "Projects"); migrationBuilder.DropTable( name: "Programmes"); migrationBuilder.DropTable( name: "Instruments"); migrationBuilder.DropTable( name: "Portfolios"); migrationBuilder.DropTable( name: "Users"); } } }