using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PowderCoating.Infrastructure.Migrations { /// public partial class AddBudgetsAndYearEndClose : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Budgets", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), FiscalYear = table.Column(type: "int", nullable: false), Notes = table.Column(type: "nvarchar(max)", nullable: true), IsDefault = table.Column(type: "bit", nullable: false), CompanyId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Budgets", x => x.Id); }); migrationBuilder.CreateTable( name: "YearEndCloses", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ClosedYear = table.Column(type: "int", nullable: false), ClosedAt = table.Column(type: "datetime2", nullable: false), ClosedBy = table.Column(type: "nvarchar(max)", nullable: true), JournalEntryId = table.Column(type: "int", nullable: false), CompanyId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_YearEndCloses", x => x.Id); table.ForeignKey( name: "FK_YearEndCloses_JournalEntries_JournalEntryId", column: x => x.JournalEntryId, principalTable: "JournalEntries", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "BudgetLines", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), BudgetId = table.Column(type: "int", nullable: false), AccountId = table.Column(type: "int", nullable: false), Jan = table.Column(type: "decimal(18,2)", nullable: false), Feb = table.Column(type: "decimal(18,2)", nullable: false), Mar = table.Column(type: "decimal(18,2)", nullable: false), Apr = table.Column(type: "decimal(18,2)", nullable: false), May = table.Column(type: "decimal(18,2)", nullable: false), Jun = table.Column(type: "decimal(18,2)", nullable: false), Jul = table.Column(type: "decimal(18,2)", nullable: false), Aug = table.Column(type: "decimal(18,2)", nullable: false), Sep = table.Column(type: "decimal(18,2)", nullable: false), Oct = table.Column(type: "decimal(18,2)", nullable: false), Nov = table.Column(type: "decimal(18,2)", nullable: false), Dec = table.Column(type: "decimal(18,2)", nullable: false), CompanyId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_BudgetLines", x => x.Id); table.ForeignKey( name: "FK_BudgetLines_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_BudgetLines_Budgets_BudgetId", column: x => x.BudgetId, principalTable: "Budgets", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 1, column: "CreatedAt", value: new DateTime(2026, 5, 10, 16, 55, 8, 322, DateTimeKind.Utc).AddTicks(966)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 2, column: "CreatedAt", value: new DateTime(2026, 5, 10, 16, 55, 8, 322, DateTimeKind.Utc).AddTicks(974)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 3, column: "CreatedAt", value: new DateTime(2026, 5, 10, 16, 55, 8, 322, DateTimeKind.Utc).AddTicks(976)); migrationBuilder.CreateIndex( name: "IX_BudgetLines_AccountId", table: "BudgetLines", column: "AccountId"); migrationBuilder.CreateIndex( name: "IX_BudgetLines_BudgetId", table: "BudgetLines", column: "BudgetId"); migrationBuilder.CreateIndex( name: "IX_YearEndCloses_JournalEntryId", table: "YearEndCloses", column: "JournalEntryId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "BudgetLines"); migrationBuilder.DropTable( name: "YearEndCloses"); migrationBuilder.DropTable( name: "Budgets"); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 1, column: "CreatedAt", value: new DateTime(2026, 5, 10, 16, 0, 49, 626, DateTimeKind.Utc).AddTicks(4004)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 2, column: "CreatedAt", value: new DateTime(2026, 5, 10, 16, 0, 49, 626, DateTimeKind.Utc).AddTicks(4009)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 3, column: "CreatedAt", value: new DateTime(2026, 5, 10, 16, 0, 49, 626, DateTimeKind.Utc).AddTicks(4011)); } } }