⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.
Context
src/selfhost/pg-dialect.ts:9-25's REPLACE_CONFLICT_KEYS map requires every table used with INSERT OR REPLACE to have an entry, or translateInsertOr() throws pg_dialect: INSERT OR REPLACE into '<table>' has no known conflict key (line 131). Migration migrations/0177_orb_reuse_counters.sql:16 (#8820) added orb_reuse_counters with PRIMARY KEY (instance_id, day) and a real INSERT OR REPLACE writer at src/orb/ingest.ts:226, but nobody added the matching entry to the map -- every other table that uses INSERT OR REPLACE (system_flags, tunables_overrides, tunables_overrides_shadow, orb_export_cursor, orb_signals, ams_signals) has one. Any self-hosted Postgres instance running the hourly ORB export throws on its first orb_reuse_counters write.
Requirements
Add orb_reuse_counters: ["instance_id", "day"] to REPLACE_CONFLICT_KEYS in src/selfhost/pg-dialect.ts.
Deliverables
All of the above Deliverables are required in the same PR unless the deliverable text itself states otherwise.
Test Coverage Requirements
src/** -- 99%+ patch coverage, branch-counted, on the new map entry and its test.
Expected Outcome
A self-hosted Postgres instance's hourly ORB export no longer throws on its first orb_reuse_counters write.
Links & Resources
src/selfhost/pg-dialect.ts:9-25,131
migrations/0177_orb_reuse_counters.sql:16
src/orb/ingest.ts:226
test/unit/selfhost-pg-dialect.test.ts
Context
src/selfhost/pg-dialect.ts:9-25'sREPLACE_CONFLICT_KEYSmap requires every table used withINSERT OR REPLACEto have an entry, ortranslateInsertOr()throwspg_dialect: INSERT OR REPLACE into '<table>' has no known conflict key(line 131). Migrationmigrations/0177_orb_reuse_counters.sql:16(#8820) addedorb_reuse_counterswithPRIMARY KEY (instance_id, day)and a realINSERT OR REPLACEwriter atsrc/orb/ingest.ts:226, but nobody added the matching entry to the map -- every other table that usesINSERT OR REPLACE(system_flags,tunables_overrides,tunables_overrides_shadow,orb_export_cursor,orb_signals,ams_signals) has one. Any self-hosted Postgres instance running the hourly ORB export throws on its firstorb_reuse_counterswrite.Requirements
Add
orb_reuse_counters: ["instance_id", "day"]toREPLACE_CONFLICT_KEYSinsrc/selfhost/pg-dialect.ts.Deliverables
REPLACE_CONFLICT_KEYSincludesorb_reuse_counters: ["instance_id", "day"]test/unit/selfhost-pg-dialect.test.tsreferencing this table, assertingtranslateInsertOrsucceeds instead of throwingAll of the above Deliverables are required in the same PR unless the deliverable text itself states otherwise.
Test Coverage Requirements
src/**-- 99%+ patch coverage, branch-counted, on the new map entry and its test.Expected Outcome
A self-hosted Postgres instance's hourly ORB export no longer throws on its first
orb_reuse_counterswrite.Links & Resources
src/selfhost/pg-dialect.ts:9-25,131migrations/0177_orb_reuse_counters.sql:16src/orb/ingest.ts:226test/unit/selfhost-pg-dialect.test.ts