Skip to main content

max / makenotwork

1020 B · 18 lines History Blame Raw
1 -- Name each fetched dump by the database it is of, so `migration_dry_run` can
2 -- run a check per database instead of only against the server's.
3 --
4 -- multithreaded ships its own 36+ migrations and applies them with
5 -- `sqlx::migrate!()` at boot against its own `multithreaded` database. The gate
6 -- was server-only, so an edited already-applied mt migration would not fail a
7 -- dry run — it would fail to boot in prod. Restoring the server dump for that
8 -- check would be worse than no check: mt's migrations would run against a
9 -- schema and a `_sqlx_migrations` table belonging to a different service.
10 --
11 -- Existing rows are the server's dump, which is why the default backfills them
12 -- to 'server' — the same name the historical single `[backup]` table takes.
13 ALTER TABLE backups ADD COLUMN name TEXT NOT NULL DEFAULT 'server';
14
15 -- Both readers filter by name and take the newest: the gate's freshness check
16 -- and the fetch's plausibility floor.
17 CREATE INDEX backups_name_fetched ON backups(name, fetched_at);
18