using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace ROLAC.API.Migrations { /// public partial class AddForm1099RecipientTracking : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "Form1099BoxId", table: "ExpenseSubCategories", type: "integer", nullable: true); migrationBuilder.AddColumn( name: "PayeeId", table: "Expenses", type: "integer", nullable: true); migrationBuilder.AddColumn( name: "Form1099BoxId", table: "ExpenseCategoryGroups", type: "integer", nullable: true); migrationBuilder.CreateTable( name: "Form1099Boxes", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), BoxCode = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), Name_en = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), Name_zh = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), FormType = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), SortOrder = table.Column(type: "integer", nullable: false), IsActive = table.Column(type: "boolean", nullable: false), 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_Form1099Boxes", x => x.Id); }); migrationBuilder.CreateTable( name: "Payee1099s", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), LegalName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), DisplayName = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), MemberId = table.Column(type: "integer", nullable: true), TaxClassification = table.Column(type: "character varying(40)", maxLength: 40, nullable: false), Is1099Tracked = table.Column(type: "boolean", nullable: false), TinType = table.Column(type: "character varying(10)", maxLength: 10, nullable: true), TinEncrypted = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), TinLast4 = table.Column(type: "character varying(4)", maxLength: 4, nullable: true), AddressLine1 = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), AddressLine2 = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), City = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), State = table.Column(type: "character varying(2)", maxLength: 2, nullable: true), Zip = table.Column(type: "character varying(10)", maxLength: 10, nullable: true), Email = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), Phone = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), W9Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Missing"), W9ReceivedDate = table.Column(type: "date", nullable: true), W9BlobPath = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), IsActive = table.Column(type: "boolean", nullable: false), Notes = 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), 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_Payee1099s", x => x.Id); table.ForeignKey( name: "FK_Payee1099s_Members_MemberId", column: x => x.MemberId, principalTable: "Members", principalColumn: "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateIndex( name: "IX_ExpenseSubCategories_Form1099BoxId", table: "ExpenseSubCategories", column: "Form1099BoxId"); migrationBuilder.CreateIndex( name: "IX_Expenses_PayeeId", table: "Expenses", column: "PayeeId"); migrationBuilder.CreateIndex( name: "IX_ExpenseCategoryGroups_Form1099BoxId", table: "ExpenseCategoryGroups", column: "Form1099BoxId"); migrationBuilder.CreateIndex( name: "IX_Form1099Boxes_BoxCode", table: "Form1099Boxes", column: "BoxCode", unique: true); migrationBuilder.CreateIndex( name: "IX_Payee1099s_MemberId", table: "Payee1099s", column: "MemberId"); migrationBuilder.AddForeignKey( name: "FK_ExpenseCategoryGroups_Form1099Boxes_Form1099BoxId", table: "ExpenseCategoryGroups", column: "Form1099BoxId", principalTable: "Form1099Boxes", principalColumn: "Id", onDelete: ReferentialAction.SetNull); migrationBuilder.AddForeignKey( name: "FK_Expenses_Payee1099s_PayeeId", table: "Expenses", column: "PayeeId", principalTable: "Payee1099s", principalColumn: "Id", onDelete: ReferentialAction.SetNull); migrationBuilder.AddForeignKey( name: "FK_ExpenseSubCategories_Form1099Boxes_Form1099BoxId", table: "ExpenseSubCategories", column: "Form1099BoxId", principalTable: "Form1099Boxes", principalColumn: "Id", onDelete: ReferentialAction.SetNull); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_ExpenseCategoryGroups_Form1099Boxes_Form1099BoxId", table: "ExpenseCategoryGroups"); migrationBuilder.DropForeignKey( name: "FK_Expenses_Payee1099s_PayeeId", table: "Expenses"); migrationBuilder.DropForeignKey( name: "FK_ExpenseSubCategories_Form1099Boxes_Form1099BoxId", table: "ExpenseSubCategories"); migrationBuilder.DropTable( name: "Form1099Boxes"); migrationBuilder.DropTable( name: "Payee1099s"); migrationBuilder.DropIndex( name: "IX_ExpenseSubCategories_Form1099BoxId", table: "ExpenseSubCategories"); migrationBuilder.DropIndex( name: "IX_Expenses_PayeeId", table: "Expenses"); migrationBuilder.DropIndex( name: "IX_ExpenseCategoryGroups_Form1099BoxId", table: "ExpenseCategoryGroups"); migrationBuilder.DropColumn( name: "Form1099BoxId", table: "ExpenseSubCategories"); migrationBuilder.DropColumn( name: "PayeeId", table: "Expenses"); migrationBuilder.DropColumn( name: "Form1099BoxId", table: "ExpenseCategoryGroups"); } } }