Skip to content

Commit f71c593

Browse files
authored
fix(aggregator): rename labellers table via forward migration (#2111)
Migration 0001 was edited in place to rename `labellers` -> `labelers` after shipping on main. Databases that already applied 0001 never see the edit, so they keep `labellers` while every query in src/ reads `labelers`, failing with `no such table`. Restore 0001 to main's byte-for-byte schema and add 0004 to rename the table forward. Both fresh installs and main upgrades now converge on `labelers`. Adds an upgrade test that provisions main's frozen 0001, applies the live set, and asserts the table is queryable.
1 parent 7074e81 commit f71c593

7 files changed

Lines changed: 486 additions & 6 deletions

File tree

apps/aggregator/migrations/0001_init.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ CREATE TABLE mirrored_artifacts (
178178
);
179179

180180
------------------------------------------------------------------------------
181-
-- Labels (populated when the labeler integration lands)
181+
-- Labels (populated when the labeller integration lands)
182182
------------------------------------------------------------------------------
183183

184184
-- Append-only label history. Every label received is written here, including
185185
-- negations. Current state is derived from latest cts per (src, uri, val) and
186186
-- projected into label_state below for hot-path lookups.
187187
CREATE TABLE labels (
188-
src TEXT NOT NULL, -- labeler DID
188+
src TEXT NOT NULL, -- labeller DID
189189
uri TEXT NOT NULL, -- AT URI of subject
190190
cid TEXT, -- optional version-specific CID
191191
val TEXT NOT NULL, -- e.g. 'security:yanked', '!takedown'
@@ -229,8 +229,8 @@ CREATE TABLE label_state (
229229
CREATE INDEX idx_label_state_enforce ON label_state(uri, val, trusted)
230230
WHERE neg = 0 AND trusted = 1;
231231

232-
-- Trusted/known labelers (operator config, edited via deployment).
233-
CREATE TABLE labelers (
232+
-- Trusted/known labellers (operator config, edited via deployment).
233+
CREATE TABLE labellers (
234234
did TEXT PRIMARY KEY,
235235
endpoint TEXT NOT NULL, -- subscribeLabels URL
236236
signing_key TEXT NOT NULL, -- cached #atproto_label key
@@ -278,9 +278,9 @@ END;
278278
------------------------------------------------------------------------------
279279

280280
-- Cursor state for ingest sources (Jetstream microsecond timestamp,
281-
-- subscribeLabels seq cursors per labeler, etc.).
281+
-- subscribeLabels seq cursors per labeller, etc.).
282282
CREATE TABLE ingest_state (
283-
source TEXT PRIMARY KEY, -- 'jetstream', 'labeler:did:web:labels.example.com', etc.
283+
source TEXT PRIMARY KEY, -- 'jetstream', 'labeller:did:web:labels.example.com', etc.
284284
cursor TEXT NOT NULL,
285285
updated_at TEXT NOT NULL
286286
);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Rename `labellers` -> `labelers` to match the spelling every query in
2+
-- `src/` uses (`labeler-resolver.ts`, `labels-consumer.ts`,
3+
-- `request-policy.ts`, `index.ts`). `0001_init.sql` shipped the table as
4+
-- `labellers` and is immutable once applied, so the correction has to land as
5+
-- a forward migration: databases provisioned by `0001` keep `labellers` and
6+
-- only this migration brings them to `labelers`.
7+
--
8+
-- No indexes, triggers, or views reference the table, so SQLite's
9+
-- `ALTER TABLE ... RENAME TO` is sufficient — there are no explicitly-named
10+
-- objects embedding the old spelling to recreate.
11+
12+
ALTER TABLE labellers RENAME TO labelers;

0 commit comments

Comments
 (0)