556abba687
Creates Form1099Boxes and Payee1099s tables; adds Form1099BoxId to ExpenseSubCategories and ExpenseCategoryGroups; adds PayeeId to Expenses. All new columns nullable, all FKs with SetNull, unique index on Form1099Boxes.BoxCode. No data backfill. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
198 lines
9.7 KiB
C#
198 lines
9.7 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace ROLAC.API.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddForm1099RecipientTracking : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "Form1099BoxId",
|
|
table: "ExpenseSubCategories",
|
|
type: "integer",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "PayeeId",
|
|
table: "Expenses",
|
|
type: "integer",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "Form1099BoxId",
|
|
table: "ExpenseCategoryGroups",
|
|
type: "integer",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Form1099Boxes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
BoxCode = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
|
Name_en = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
|
Name_zh = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
|
|
FormType = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
|
SortOrder = table.Column<int>(type: "integer", nullable: false),
|
|
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
CreatedBy = table.Column<string>(type: "character varying(450)", maxLength: 450, nullable: false),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedBy = table.Column<string>(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<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
LegalName = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
|
DisplayName = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
|
|
MemberId = table.Column<int>(type: "integer", nullable: true),
|
|
TaxClassification = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
|
|
Is1099Tracked = table.Column<bool>(type: "boolean", nullable: false),
|
|
TinType = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: true),
|
|
TinEncrypted = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
TinLast4 = table.Column<string>(type: "character varying(4)", maxLength: 4, nullable: true),
|
|
AddressLine1 = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
|
|
AddressLine2 = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
|
|
City = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
|
|
State = table.Column<string>(type: "character varying(2)", maxLength: 2, nullable: true),
|
|
Zip = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: true),
|
|
Email = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
|
|
Phone = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true),
|
|
W9Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Missing"),
|
|
W9ReceivedDate = table.Column<DateOnly>(type: "date", nullable: true),
|
|
W9BlobPath = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
|
Notes = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
CreatedBy = table.Column<string>(type: "character varying(450)", maxLength: 450, nullable: false),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedBy = table.Column<string>(type: "character varying(450)", maxLength: 450, nullable: false),
|
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
DeletedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
DeletedBy = table.Column<string>(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);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
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");
|
|
}
|
|
}
|
|
}
|