mirror of
https://github.com/block/buzz.git
synced 2026-11-03 16:01:35 +00:00
refactor(schema): stop auto-fencing new tables in desired-state bootstrap (#8620)
### Why?
This is a cleanup that brings the schema bootstrap in line with how the
codebase works today, as asked for by
[`docs/database.md`](dc25198d53/docs/database.md (L103-L124))
(#8273). Writes are now blocked during community deletion by application
admission (`begin_community_write_transaction`), and that doc's Rule 1
says new tables must not add triggers. But
`schema/community_write_fence.sql` still looped over every table with a
`community_id` column and attached the old fence trigger to it. That
meant a new table got a trigger on a fresh database and none on a
migrated one, so the two schema paths disagreed and new tenant tables
were blocked. The doc says this bootstrap change must land "before the
feature, or as the feature's first PR."
### What?
Deletes the blanket fence loop and its `\i` from `schema/schema.sql`.
Existing legacy tables keep their fences through their explicit
`schema/triggers/` files, so no current table loses its fence and
runtime behavior is unchanged. Adds a test that a new `community_id`
table stays unfenced while `events` and `users` stay fenced, and updates
`docs/database.md` and `ARCHITECTURE.md` to match. It stands on its own;
the media-sharing PRs (#8451, #8444) are the first to rely on it.
buzz-review-completed
---------
Signed-off-by: Nikolaj Goodger <ngoodger@squareup.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
--
|
||||
-- Everything SchemaBot cannot apply lives in this directory's other
|
||||
-- subdirectories: `types/`, `functions/`, `partitions/`, `triggers/` (including
|
||||
-- write-fence attachment), `seeds/`, and the `community_write_fence.sql`
|
||||
-- bootstrap. This file composes all of them into one fresh database, in load
|
||||
-- order: types → functions → tables → partitions → triggers → seeds → fence.
|
||||
-- explicit legacy write-fence attachment), and `seeds/`. This file composes
|
||||
-- them into one fresh database, in load order:
|
||||
-- types → functions → tables → partitions → triggers → seeds.
|
||||
--
|
||||
-- `./bin/pgschema apply --file schema/schema.sql` resolves the `\i` includes
|
||||
-- relative to this file (it refuses `..`). `pgschema` skips INSERTs and some
|
||||
@@ -213,6 +213,3 @@ CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||
\i seeds/operator_listener_outbox.sql
|
||||
\i seeds/relay_operator_audit.sql
|
||||
\i seeds/storage_accounting_snapshots.sql
|
||||
|
||||
-- Fence any community-scoped table that lacks an explicit attach.
|
||||
\i community_write_fence.sql
|
||||
|
||||
Reference in New Issue
Block a user