using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PowderCoating.Infrastructure.Migrations { /// public partial class AddFixedAssetsLockAnd1099 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "Is1099Vendor", table: "Vendors", type: "bit", nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "BookLockedThrough", table: "Companies", type: "datetime2", nullable: true); migrationBuilder.CreateTable( name: "FixedAssets", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), PurchaseDate = table.Column(type: "datetime2", nullable: false), PurchaseCost = table.Column(type: "decimal(18,2)", nullable: false), SalvageValue = table.Column(type: "decimal(18,2)", nullable: false), UsefulLifeMonths = table.Column(type: "int", nullable: false), AccumulatedDepreciation = table.Column(type: "decimal(18,2)", nullable: false), IsDisposed = table.Column(type: "bit", nullable: false), DisposalDate = table.Column(type: "datetime2", nullable: true), AssetAccountId = table.Column(type: "int", nullable: true), DepreciationExpenseAccountId = table.Column(type: "int", nullable: true), AccumDepreciationAccountId = table.Column(type: "int", nullable: true), 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_FixedAssets", x => x.Id); table.ForeignKey( name: "FK_FixedAssets_Accounts_AccumDepreciationAccountId", column: x => x.AccumDepreciationAccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_FixedAssets_Accounts_AssetAccountId", column: x => x.AssetAccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_FixedAssets_Accounts_DepreciationExpenseAccountId", column: x => x.DepreciationExpenseAccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "FixedAssetDepreciationEntries", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), FixedAssetId = table.Column(type: "int", nullable: false), PeriodYear = table.Column(type: "int", nullable: false), PeriodMonth = table.Column(type: "int", nullable: false), Amount = table.Column(type: "decimal(18,2)", nullable: false), JournalEntryId = table.Column(type: "int", nullable: true), 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_FixedAssetDepreciationEntries", x => x.Id); table.ForeignKey( name: "FK_FixedAssetDepreciationEntries_FixedAssets_FixedAssetId", column: x => x.FixedAssetId, principalTable: "FixedAssets", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_FixedAssetDepreciationEntries_JournalEntries_JournalEntryId", column: x => x.JournalEntryId, principalTable: "JournalEntries", principalColumn: "Id"); }); 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)); migrationBuilder.CreateIndex( name: "IX_FixedAssetDepreciationEntries_FixedAssetId", table: "FixedAssetDepreciationEntries", column: "FixedAssetId"); migrationBuilder.CreateIndex( name: "IX_FixedAssetDepreciationEntries_JournalEntryId", table: "FixedAssetDepreciationEntries", column: "JournalEntryId"); migrationBuilder.CreateIndex( name: "IX_FixedAssets_AccumDepreciationAccountId", table: "FixedAssets", column: "AccumDepreciationAccountId"); migrationBuilder.CreateIndex( name: "IX_FixedAssets_AssetAccountId", table: "FixedAssets", column: "AssetAccountId"); migrationBuilder.CreateIndex( name: "IX_FixedAssets_DepreciationExpenseAccountId", table: "FixedAssets", column: "DepreciationExpenseAccountId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "FixedAssetDepreciationEntries"); migrationBuilder.DropTable( name: "FixedAssets"); migrationBuilder.DropColumn( name: "Is1099Vendor", table: "Vendors"); migrationBuilder.DropColumn( name: "BookLockedThrough", table: "Companies"); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 1, column: "CreatedAt", value: new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(199)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 2, column: "CreatedAt", value: new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(205)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 3, column: "CreatedAt", value: new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(206)); } } }