using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace ROLAC.API.Migrations { /// public partial class AddExpenseSnapshots : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "ExpenseSnapshots", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), MinistryId = table.Column(type: "integer", nullable: false), Description = table.Column(type: "character varying(500)", maxLength: 500, nullable: false), VendorName = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), CheckNumber = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), Notes = table.Column(type: "text", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), CreatedBy = table.Column(type: "character varying(450)", maxLength: 450, nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedBy = table.Column(type: "character varying(450)", maxLength: 450, nullable: false), IsDeleted = table.Column(type: "boolean", nullable: false), DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), DeletedBy = table.Column(type: "character varying(450)", maxLength: 450, nullable: true) }, constraints: table => { table.PrimaryKey("PK_ExpenseSnapshots", x => x.Id); table.ForeignKey( name: "FK_ExpenseSnapshots_Ministries_MinistryId", column: x => x.MinistryId, principalTable: "Ministries", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ExpenseSnapshotLines", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), SnapshotId = table.Column(type: "integer", nullable: false), CategoryGroupId = table.Column(type: "integer", nullable: false), SubCategoryId = table.Column(type: "integer", nullable: false), FunctionalClass = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), Amount = table.Column(type: "numeric(18,2)", nullable: false), Description = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), CreatedBy = table.Column(type: "character varying(450)", maxLength: 450, nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedBy = table.Column(type: "character varying(450)", maxLength: 450, nullable: false) }, constraints: table => { table.PrimaryKey("PK_ExpenseSnapshotLines", x => x.Id); table.ForeignKey( name: "FK_ExpenseSnapshotLines_ExpenseCategoryGroups_CategoryGroupId", column: x => x.CategoryGroupId, principalTable: "ExpenseCategoryGroups", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ExpenseSnapshotLines_ExpenseSnapshots_SnapshotId", column: x => x.SnapshotId, principalTable: "ExpenseSnapshots", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ExpenseSnapshotLines_ExpenseSubCategories_SubCategoryId", column: x => x.SubCategoryId, principalTable: "ExpenseSubCategories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_ExpenseSnapshotLines_CategoryGroupId", table: "ExpenseSnapshotLines", column: "CategoryGroupId"); migrationBuilder.CreateIndex( name: "IX_ExpenseSnapshotLines_SnapshotId", table: "ExpenseSnapshotLines", column: "SnapshotId"); migrationBuilder.CreateIndex( name: "IX_ExpenseSnapshotLines_SubCategoryId", table: "ExpenseSnapshotLines", column: "SubCategoryId"); migrationBuilder.CreateIndex( name: "IX_ExpenseSnapshots_CreatedAt", table: "ExpenseSnapshots", column: "CreatedAt"); migrationBuilder.CreateIndex( name: "IX_ExpenseSnapshots_MinistryId", table: "ExpenseSnapshots", column: "MinistryId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ExpenseSnapshotLines"); migrationBuilder.DropTable( name: "ExpenseSnapshots"); } } }