You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 97b31b5
Browse filesBrowse the repository at this point in the historyBrowse files
chore(db): check that migrations bound their lock wait and stay append-only
A new buzz-db test fails when a relay migration after 0066, or a push
gateway migration after 0006, does not start with SET LOCAL lock_timeout.
scripts/check-migrations-append-only.sh fails when a .sql file that is
already on main is edited, renamed or deleted in either migrations
directory. It runs in CI on pull requests, in the pre-push hook and in
`just check`. BUZZ_ALLOW_MIGRATION_EDITS=1 or the migration-edit PR label
lets a deliberate rewrite through.
The prose these checks replace is shortened in docs/database.md and the
migrations AGENTS.md files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Salman Mohammed <smohammed@squareup.com>
Copy file name to clipboardExpand all lines: docs/database.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -312,7 +312,7 @@ apply:
312
312
313
313
| Location | What goes there |
314
314
|---|---|
315
-
|`migrations/NNNN_<name>.sql`| The forward migration for existing databases. Use the next free number; rebase and renumber on a collision. Never edit a merged migration: its checksum changes, and relays that run the migrator fail with sqlx `VersionMismatch`. Fix forward in a new migration. |
315
+
|`migrations/NNNN_<name>.sql`| The forward migration for existing databases, numbered after the newest on main. Merged migrations are append-only, because relays that already ran one fail with sqlx `VersionMismatch` when its checksum changes. `just migrations-append-only-check` enforces this. A deliberate rewrite that every deployment has agreed to takes the `migration-edit` PR label. |
316
316
|`schema/tables/public/<table>.sql`| The table's final `CREATE TABLE` and its `CREATE INDEX` statements, one table per file. This is the declarative schema source. |
317
317
|`schema/schema.sql`| An `\i` line for each new file, after the tables it depends on. |
318
318
|`schema/types/`, `schema/sequences/`, `schema/partitions/`, `schema/seeds/`| The matching non-table objects. The layout test permits nothing else here. `schema/` has no `functions/` or `triggers/` directory, and Rule 1 forbids adding one. |
@@ -471,8 +471,9 @@ foreign keys on `events` and `delivery_log`, apply `0104`.
471
471
472
472
### 6. Bound every lock and statement
473
473
474
-
- Every migration MUST start with `SET LOCAL lock_timeout`, and SHOULD set
475
-
`SET LOCAL statement_timeout` when a statement can scan. A migration that
474
+
- Every migration MUST start with `SET LOCAL lock_timeout` (a buzz-db test
475
+
enforces it after `0066`), and SHOULD set `SET LOCAL statement_timeout`
476
+
when a statement can scan. A migration that
476
477
cannot get its lock fails and is retried. It MUST NOT queue behind
477
478
traffic on a hot table.
478
479
- With `BUZZ_AUTO_MIGRATE` on, migrations are the whole upgrade procedure, so
0 commit comments