Files
buzz/crates/buzz-push-gateway/schema/schema.sql
Elrond 5446d493ec feat(push-gateway): declarative desired-state schema, one file per table
Add crates/buzz-push-gateway/schema/ in the SchemaBot shape the relay
uses (schema.sql \i manifest + tables/public/<table>.sql) declaring the
end state of migrations 0001-0006, plus a layout test and a
pgschema-vs-migrations catalog parity test.

Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
2026-10-16 10:13:14 -04:00

32 lines
1.6 KiB
PL/PgSQL

-- Push gateway desired-state database manifest.
--
-- The gateway's authority store is deployment-global and lives in its own
-- dedicated database, outside relay community tenancy. This directory declares
-- its end state; `../migrations/` remains the incremental path the gateway
-- binary applies at startup.
-- `src/postgres/desired_schema_postgres_tests.rs` proves the two produce the
-- same catalog.
--
-- `tables/public/<table>.sql` declares one table per file: its CREATE TABLE
-- and the CREATE INDEX statements on it, the one-table-per-file shape SchemaBot
-- reads. `tables/` is the SchemaBot schema directory and `public` is its
-- namespace, so nothing else may live under it. The gateway has no types,
-- functions, triggers, or seed rows. Its pre-migration bootstrap guard and
-- runtime-role grants are operational steps in `src/postgres.rs`, not schema.
--
-- `./bin/pgschema apply --file crates/buzz-push-gateway/schema/schema.sql`
-- resolves the `\i` includes relative to this file. Raw `psql` resolves `\i`
-- against the working directory instead, so run it from here:
-- `cd crates/buzz-push-gateway/schema && psql -f schema.sql`.
--
-- Adding a table: add `tables/public/<table>.sql` and include it below after
-- the tables it references. This file holds only `\i` lines. The layout
-- test in `src/postgres/desired_schema_postgres_tests.rs` enforces both.
\i tables/public/push_gateway_challenges.sql
\i tables/public/push_gateway_installations.sql
\i tables/public/push_gateway_delegations.sql
\i tables/public/push_gateway_endpoint_quotas.sql
\i tables/public/push_gateway_delivery_auth_replays.sql
\i tables/public/push_gateway_delivery_request_replays.sql