Files
pfm/PostFundManagement.Infrastructure/Database/Migrations/20260820113615_AddedActivityNotification.cs

456 lines
19 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace PostFundManagement.Infrastructure.Database.Migrations
{
/// <inheritdoc />
public partial class AddedActivityNotification : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Evidences_Indicators_IndicatorId",
table: "Evidences");
migrationBuilder.DropForeignKey(
name: "FK_Programmes_Instruments_InstrumentId",
table: "Programmes");
migrationBuilder.DropForeignKey(
name: "FK_Projects_Programmes_ProgrammeId",
table: "Projects");
migrationBuilder.DropIndex(
name: "IX_Programmes_InstrumentId",
table: "Programmes");
migrationBuilder.DropColumn(
name: "InstrumentId",
table: "Programmes");
migrationBuilder.AddColumn<int>(
name: "ProjectType",
table: "Projects",
type: "integer",
nullable: false,
defaultValueSql: "10");
migrationBuilder.AddColumn<int>(
name: "Sector",
table: "Projects",
type: "integer",
nullable: false,
defaultValueSql: "11");
migrationBuilder.AddColumn<int>(
name: "Priority",
table: "Milestones",
type: "integer",
nullable: false,
defaultValueSql: "1");
migrationBuilder.AddColumn<Guid>(
name: "AssignedTo",
table: "Issues",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Resolution",
table: "Issues",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<long>(
name: "ProgrammeId",
table: "Instruments",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<long>(
name: "ActivityId",
table: "Evidences",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<int>(
name: "Type",
table: "Evidences",
type: "integer",
nullable: false,
defaultValueSql: "9");
migrationBuilder.CreateTable(
name: "Activities",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ProjectId = table.Column<long>(type: "bigint", nullable: false),
MilestoneId = table.Column<long>(type: "bigint", nullable: false),
CreatedBy = table.Column<Guid>(type: "uuid", nullable: false),
UpdatedBy = table.Column<Guid>(type: "uuid", nullable: true),
ApprovedBy = table.Column<Guid>(type: "uuid", nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Category = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Status = table.Column<int>(type: "integer", nullable: false, defaultValueSql: "1"),
Amount = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
Title = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false),
PerformedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Activities", x => x.Id);
table.ForeignKey(
name: "FK_Activities_Milestones_MilestoneId",
column: x => x.MilestoneId,
principalTable: "Milestones",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Activities_Projects_ProjectId",
column: x => x.ProjectId,
principalTable: "Projects",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Activities_Users_ApprovedBy",
column: x => x.ApprovedBy,
principalTable: "Users",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Activities_Users_CreatedBy",
column: x => x.CreatedBy,
principalTable: "Users",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Activities_Users_UpdatedBy",
column: x => x.UpdatedBy,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Invites",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
OrganisationId = table.Column<long>(type: "bigint", nullable: false),
InvitedOrganisationId = table.Column<long>(type: "bigint", nullable: false),
AwardId = table.Column<long>(type: "bigint", nullable: false),
ContractId = table.Column<long>(type: "bigint", nullable: false),
Recipient = table.Column<Guid>(type: "uuid", nullable: false),
CreatedBy = table.Column<Guid>(type: "uuid", nullable: false),
UpdatedBy = table.Column<Guid>(type: "uuid", nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Invites", x => x.Id);
table.ForeignKey(
name: "FK_Invites_Awards_AwardId",
column: x => x.AwardId,
principalTable: "Awards",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Invites_Contracts_ContractId",
column: x => x.ContractId,
principalTable: "Contracts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Invites_Organisations_InvitedOrganisationId",
column: x => x.InvitedOrganisationId,
principalTable: "Organisations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Invites_Organisations_OrganisationId",
column: x => x.OrganisationId,
principalTable: "Organisations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Invites_Users_Recipient",
column: x => x.Recipient,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Notifications",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
OrganisationId = table.Column<long>(type: "bigint", nullable: false),
Recipient = table.Column<Guid>(type: "uuid", nullable: false),
Platform = table.Column<int>(type: "integer", nullable: false, defaultValueSql: "1"),
Status = table.Column<int>(type: "integer", nullable: false, defaultValueSql: "1"),
Subject = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
Message = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: false),
Destination = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
SentAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Error = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Notifications", x => x.Id);
table.ForeignKey(
name: "FK_Notifications_Organisations_OrganisationId",
column: x => x.OrganisationId,
principalTable: "Organisations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Notifications_Users_Recipient",
column: x => x.Recipient,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Issues_AssignedTo",
table: "Issues",
column: "AssignedTo");
migrationBuilder.CreateIndex(
name: "IX_Instruments_ProgrammeId",
table: "Instruments",
column: "ProgrammeId");
migrationBuilder.CreateIndex(
name: "IX_Evidences_ActivityId",
table: "Evidences",
column: "ActivityId");
migrationBuilder.CreateIndex(
name: "IX_Activities_ApprovedBy",
table: "Activities",
column: "ApprovedBy");
migrationBuilder.CreateIndex(
name: "IX_Activities_CreatedBy",
table: "Activities",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_Activities_MilestoneId",
table: "Activities",
column: "MilestoneId");
migrationBuilder.CreateIndex(
name: "IX_Activities_ProjectId",
table: "Activities",
column: "ProjectId");
migrationBuilder.CreateIndex(
name: "IX_Activities_UpdatedBy",
table: "Activities",
column: "UpdatedBy");
migrationBuilder.CreateIndex(
name: "IX_Invites_AwardId",
table: "Invites",
column: "AwardId");
migrationBuilder.CreateIndex(
name: "IX_Invites_ContractId",
table: "Invites",
column: "ContractId");
migrationBuilder.CreateIndex(
name: "IX_Invites_InvitedOrganisationId",
table: "Invites",
column: "InvitedOrganisationId");
migrationBuilder.CreateIndex(
name: "IX_Invites_OrganisationId",
table: "Invites",
column: "OrganisationId");
migrationBuilder.CreateIndex(
name: "IX_Invites_Recipient",
table: "Invites",
column: "Recipient");
migrationBuilder.CreateIndex(
name: "IX_Notifications_OrganisationId",
table: "Notifications",
column: "OrganisationId");
migrationBuilder.CreateIndex(
name: "IX_Notifications_Recipient",
table: "Notifications",
column: "Recipient");
migrationBuilder.AddForeignKey(
name: "FK_Evidences_Activities_ActivityId",
table: "Evidences",
column: "ActivityId",
principalTable: "Activities",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Evidences_Indicators_IndicatorId",
table: "Evidences",
column: "IndicatorId",
principalTable: "Indicators",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Instruments_Programmes_ProgrammeId",
table: "Instruments",
column: "ProgrammeId",
principalTable: "Programmes",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Issues_Users_AssignedTo",
table: "Issues",
column: "AssignedTo",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Projects_Programmes_ProgrammeId",
table: "Projects",
column: "ProgrammeId",
principalTable: "Programmes",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Evidences_Activities_ActivityId",
table: "Evidences");
migrationBuilder.DropForeignKey(
name: "FK_Evidences_Indicators_IndicatorId",
table: "Evidences");
migrationBuilder.DropForeignKey(
name: "FK_Instruments_Programmes_ProgrammeId",
table: "Instruments");
migrationBuilder.DropForeignKey(
name: "FK_Issues_Users_AssignedTo",
table: "Issues");
migrationBuilder.DropForeignKey(
name: "FK_Projects_Programmes_ProgrammeId",
table: "Projects");
migrationBuilder.DropTable(
name: "Activities");
migrationBuilder.DropTable(
name: "Invites");
migrationBuilder.DropTable(
name: "Notifications");
migrationBuilder.DropIndex(
name: "IX_Issues_AssignedTo",
table: "Issues");
migrationBuilder.DropIndex(
name: "IX_Instruments_ProgrammeId",
table: "Instruments");
migrationBuilder.DropIndex(
name: "IX_Evidences_ActivityId",
table: "Evidences");
migrationBuilder.DropColumn(
name: "ProjectType",
table: "Projects");
migrationBuilder.DropColumn(
name: "Sector",
table: "Projects");
migrationBuilder.DropColumn(
name: "Priority",
table: "Milestones");
migrationBuilder.DropColumn(
name: "AssignedTo",
table: "Issues");
migrationBuilder.DropColumn(
name: "Resolution",
table: "Issues");
migrationBuilder.DropColumn(
name: "ProgrammeId",
table: "Instruments");
migrationBuilder.DropColumn(
name: "ActivityId",
table: "Evidences");
migrationBuilder.DropColumn(
name: "Type",
table: "Evidences");
migrationBuilder.AddColumn<long>(
name: "InstrumentId",
table: "Programmes",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.CreateIndex(
name: "IX_Programmes_InstrumentId",
table: "Programmes",
column: "InstrumentId");
migrationBuilder.AddForeignKey(
name: "FK_Evidences_Indicators_IndicatorId",
table: "Evidences",
column: "IndicatorId",
principalTable: "Indicators",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Programmes_Instruments_InstrumentId",
table: "Programmes",
column: "InstrumentId",
principalTable: "Instruments",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Projects_Programmes_ProgrammeId",
table: "Projects",
column: "ProgrammeId",
principalTable: "Programmes",
principalColumn: "Id");
}
}
}