Merge pull request #294 from Hestia-Homes/db/landlord-override-migrations

Add landlord-override DB migrations (0215 data + 0216 schema)
This commit is contained in:
Jun-te Kim 2026-05-29 11:35:44 +01:00 committed by GitHub
commit 49d3edc6cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 20297 additions and 0 deletions

View file

@ -0,0 +1,22 @@
-- One-shot inversion of bulk_address_uploads.column_mapping.
--
-- Old shape: { "<source header>": "<internal field>" } (header -> field), with
-- unmapped columns stored as "<header>": "skip".
-- New shape: { "<internal field>": "<source header>" } (field -> header), with
-- unmapped fields simply absent. See ADR-0003 and the WIP plan (Q2.2/Q5).
--
-- 'skip' entries are dropped. On a legacy duplicate (two headers -> one field),
-- jsonb_object_agg keeps the last header — the new address-uniqueness rule
-- forbids that going forward anyway. No-op on NULL/empty mappings, so this is
-- safe regardless of data volume. One-shot: assumes rows are still old-shape.
UPDATE "bulk_address_uploads"
SET "column_mapping" = COALESCE(
(
SELECT jsonb_object_agg(elem.value, elem.key)
FROM jsonb_each_text("column_mapping") AS elem
WHERE elem.value <> 'skip'
),
'{}'::jsonb
)
WHERE "column_mapping" IS NOT NULL
AND "column_mapping" <> '{}'::jsonb;

View file

@ -0,0 +1 @@
ALTER TABLE "sub_task" ADD COLUMN "service" text;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1506,6 +1506,20 @@
"when": 1779969672088,
"tag": "0214_superb_maelstrom",
"breakpoints": true
},
{
"idx": 215,
"version": "7",
"when": 1779991310301,
"tag": "0215_invert_column_mapping",
"breakpoints": true
},
{
"idx": 216,
"version": "7",
"when": 1779992128370,
"tag": "0216_add_subtask_service",
"breakpoints": true
}
]
}

View file

@ -14,6 +14,10 @@ export const subTasks = pgTable("sub_task", {
status: text("status").notNull().default("In Progress"),
// Which pipeline this subtask belongs to, e.g. "address2uprn" or
// "landlord_description_overrides". NULL = legacy / address. See ADR-0003.
service: text("service"),
inputs: text("inputs"), // could later change to JSONB if desired
outputs: text("outputs"),
cloudLogsURL: text("cloud_logs_url"),