Add multi_entry_ordering column to bulk_address_uploads

Additive nullable jsonb column for the user-confirmed building-part ordering
(ADR-0004, issue #297), generated off main. No data migration. The jsonb shape
type is co-located with the column so the schema is self-contained.

Split out as its own migration PR so the DB change can be approved and deployed
independently of the feature's app code.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-02 13:53:05 +00:00
parent 69fd6ac30c
commit b84bcd848d
4 changed files with 10164 additions and 0 deletions

View file

@ -0,0 +1 @@
ALTER TABLE "bulk_address_uploads" ADD COLUMN "multi_entry_ordering" jsonb;

File diff suppressed because it is too large Load diff

View file

@ -1527,6 +1527,13 @@
"when": 1780404222902,
"tag": "0217_gray_hellion",
"breakpoints": true
},
{
"idx": 218,
"version": "7",
"when": 1780408378351,
"tag": "0218_natural_umar",
"breakpoints": true
}
]
}

View file

@ -25,6 +25,17 @@ export interface MultiEntrySummary {
sample: MultiEntrySample | null;
}
// User-confirmed building-part ordering (ADR-0004). Keyed by entry-count so it
// can hold more than one count later; this iteration populates only the
// largest. permutations[count][k] = the 0-based file position holding building
// part k, where 0 = Main building, 1..N-1 = Extension 1..N-1.
// e.g. { "2": [1, 0] } => for 2-part rows the main building is file position 1.
export interface MultiEntryOrdering {
permutations: Record<string, number[]>;
// Set once the user confirms; gates Finalise when the upload is multi-entry.
confirmed: boolean;
}
export const bulkAddressUploads = pgTable("bulk_address_uploads", {
id: uuid("id").defaultRandom().primaryKey(),
portfolioId: text("portfolio_id").notNull(),
@ -38,6 +49,8 @@ export const bulkAddressUploads = pgTable("bulk_address_uploads", {
// Multi-entry building-part detection, computed at start-address-matching
// and read by the awaiting_review review surface (ADR-0004).
multiEntrySummary: jsonb("multi_entry_summary").$type<MultiEntrySummary>(),
// User-confirmed building-part ordering for the multi-entry sample (ADR-0004).
multiEntryOrdering: jsonb("multi_entry_ordering").$type<MultiEntryOrdering>(),
taskId: uuid("task_id"),
combinedOutputS3Uri: text("combined_output_s3_uri"),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),