feat(1099): EF migration for Payee1099, Form1099Box, mapping columns

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>
This commit is contained in:
Chris Chen
2026-06-25 17:14:57 -07:00
parent 1a8002015a
commit 556abba687
3 changed files with 3098 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,197 @@
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");
}
}
}
@@ -598,6 +598,9 @@ namespace ROLAC.API.Migrations
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<int?>("PayeeId")
.HasColumnType("integer");
b.Property<string>("ReceiptBlobPath")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
@@ -652,6 +655,8 @@ namespace ROLAC.API.Migrations
b.HasIndex("MinistryId");
b.HasIndex("PayeeId");
b.HasIndex("Status")
.HasFilter("\"IsDeleted\" = false");
@@ -674,6 +679,9 @@ namespace ROLAC.API.Migrations
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<int?>("Form1099BoxId")
.HasColumnType("integer");
b.Property<int?>("Form990LineId")
.HasColumnType("integer");
@@ -702,6 +710,8 @@ namespace ROLAC.API.Migrations
b.HasKey("Id");
b.HasIndex("Form1099BoxId");
b.HasIndex("Form990LineId");
b.ToTable("ExpenseCategoryGroups");
@@ -900,6 +910,9 @@ namespace ROLAC.API.Migrations
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<int?>("Form1099BoxId")
.HasColumnType("integer");
b.Property<int?>("Form990LineId")
.HasColumnType("integer");
@@ -931,6 +944,8 @@ namespace ROLAC.API.Migrations
b.HasKey("Id");
b.HasIndex("Form1099BoxId");
b.HasIndex("Form990LineId");
b.HasIndex("GroupId");
@@ -976,6 +991,63 @@ namespace ROLAC.API.Migrations
b.ToTable("FamilyUnits");
});
modelBuilder.Entity("ROLAC.API.Entities.Form1099Box", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("BoxCode")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<string>("FormType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("Name_en")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Name_zh")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<int>("SortOrder")
.HasColumnType("integer");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.HasKey("Id");
b.HasIndex("BoxCode")
.IsUnique();
b.ToTable("Form1099Boxes");
});
modelBuilder.Entity("ROLAC.API.Entities.Form990ExpenseLine", b =>
{
b.Property<int>("Id")
@@ -1925,6 +1997,128 @@ namespace ROLAC.API.Migrations
b.ToTable("OfferingSessions");
});
modelBuilder.Entity("ROLAC.API.Entities.Payee1099", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("AddressLine1")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("AddressLine2")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("City")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<DateTimeOffset?>("DeletedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DeletedBy")
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<string>("DisplayName")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Email")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<bool>("Is1099Tracked")
.HasColumnType("boolean");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<string>("LegalName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<int?>("MemberId")
.HasColumnType("integer");
b.Property<string>("Notes")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<string>("Phone")
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<string>("State")
.HasMaxLength(2)
.HasColumnType("character varying(2)");
b.Property<string>("TaxClassification")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("character varying(40)");
b.Property<string>("TinEncrypted")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<string>("TinLast4")
.HasMaxLength(4)
.HasColumnType("character varying(4)");
b.Property<string>("TinType")
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)");
b.Property<string>("W9BlobPath")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<DateOnly?>("W9ReceivedDate")
.HasColumnType("date");
b.Property<string>("W9Status")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasDefaultValue("Missing");
b.Property<string>("Zip")
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.HasKey("Id");
b.HasIndex("MemberId");
b.ToTable("Payee1099s");
});
modelBuilder.Entity("ROLAC.API.Entities.RefreshToken", b =>
{
b.Property<int>("Id")
@@ -2208,18 +2402,32 @@ namespace ROLAC.API.Migrations
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ROLAC.API.Entities.Payee1099", "Payee")
.WithMany()
.HasForeignKey("PayeeId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("Member");
b.Navigation("Ministry");
b.Navigation("Payee");
});
modelBuilder.Entity("ROLAC.API.Entities.ExpenseCategoryGroup", b =>
{
b.HasOne("ROLAC.API.Entities.Form1099Box", "Form1099Box")
.WithMany()
.HasForeignKey("Form1099BoxId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("ROLAC.API.Entities.Form990ExpenseLine", "Form990Line")
.WithMany()
.HasForeignKey("Form990LineId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("Form1099Box");
b.Navigation("Form990Line");
});
@@ -2290,6 +2498,11 @@ namespace ROLAC.API.Migrations
modelBuilder.Entity("ROLAC.API.Entities.ExpenseSubCategory", b =>
{
b.HasOne("ROLAC.API.Entities.Form1099Box", "Form1099Box")
.WithMany()
.HasForeignKey("Form1099BoxId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("ROLAC.API.Entities.Form990ExpenseLine", "Form990Line")
.WithMany()
.HasForeignKey("Form990LineId")
@@ -2301,6 +2514,8 @@ namespace ROLAC.API.Migrations
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Form1099Box");
b.Navigation("Form990Line");
b.Navigation("Group");
@@ -2380,6 +2595,16 @@ namespace ROLAC.API.Migrations
b.Navigation("MessagingGroup");
});
modelBuilder.Entity("ROLAC.API.Entities.Payee1099", b =>
{
b.HasOne("ROLAC.API.Entities.Member", "Member")
.WithMany()
.HasForeignKey("MemberId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("Member");
});
modelBuilder.Entity("ROLAC.API.Entities.RefreshToken", b =>
{
b.HasOne("ROLAC.API.Entities.AppUser", "User")