Force catalog_items.offer_id to always equal its own row id

Every write path now sets offer_id = catalog_items.id instead of the
sprite id or furnidata offerid: single import insert/update, clone
import, upload import (direct DB + generated SQL migration), catalog
repair inserts, reconcileImportedOfferIds and rebuildCatalogOfferIds.

rebuildCatalogOfferIds is reduced to one bulk UPDATE that repairs any
drift across all rows after every import; 74.838 legacy rows were
repaired on the live database with this change.
This commit is contained in:
openhands committed 2026-08-23 13:42:47 +02:00
1 parent adb56eb80b
commit 5311ee1fb8
10 files changed
+45 -103

No files matched your search

+8 -3
View File
@@ -282,15 +282,20 @@ describeGuard("live furni import / catalog ID consistency (sandbox DB)", () => {
expect(row.spriteId).toBe(id);
const [catalog] = (await db.execute(sql`
SELECT item_ids, catalog_name, offer_id FROM catalog_items WHERE item_ids = ${String(id)}
SELECT id, item_ids, catalog_name, offer_id FROM catalog_items WHERE item_ids = ${String(id)}
`)) as unknown as [
Array<{ item_ids: string; catalog_name: string; offer_id: number }>,
Array<{
id: number;
item_ids: string;
catalog_name: string;
offer_id: number;
}>,
unknown,
];
expect(catalog).toHaveLength(1);
expect(catalog[0].item_ids).toBe(String(id));
expect(catalog[0].catalog_name).toBe(classname);
expect(catalog[0].offer_id).toBe(id);
expect(catalog[0].offer_id).toBe(catalog[0].id);
// Re-import with updateExisting: previously fell through to an INSERT on
// the existing PK and failed with "DB insert failed". Must now succeed.