Skip to content

Commit 0d656f1

Browse files
authored
Remove obsolete duroxide migration verification references (#83)
The gen-duroxide-install-sql.sh and verify-duroxide-migrations.sh scripts were deleted as part of the BGW-managed migrations work, but several references remained: - copilot-setup-steps.yml: CI step invoking verify-duroxide-migrations.sh - README.md: "Verifying Duroxide Migrations" section - extension_lifecycle.md: section 1 described the old migration SQL hand-over workflow with gen/verify scripts and sql/duroxide_upstream Remove the dangling CI step and README section. Rewrite extension_lifecycle.md section 1 to reflect the current architecture (empty duroxide schema created by CREATE EXTENSION, populated by BGW via ApplyAll).
1 parent 0e46f6a commit 0d656f1

3 files changed

Lines changed: 8 additions & 48 deletions

File tree

.github/workflows/copilot-setup-steps.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,3 @@ jobs:
112112
- name: Prefetch Rust dependencies
113113
run: |
114114
cargo fetch
115-
116-
- name: Verify duroxide migrations match upstream
117-
run: ./scripts/verify-duroxide-migrations.sh

README.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,6 @@ Complex integration tests with Docker:
135135

136136
See [tests/e2e/](tests/e2e/) for details.
137137

138-
## Verifying Duroxide Migrations
139-
140-
pg_durable includes checked-in copies of duroxide-pg-opt migration SQL files to ensure the extension owns the duroxide schema. The `duroxide-pg-opt` submodule provides the upstream source. To verify the copies match:
141-
142-
```bash
143-
# Ensure the submodule is initialized
144-
git submodule update --init
145-
146-
# Verify migrations match upstream
147-
./scripts/verify-duroxide-migrations.sh
148-
```
149-
150-
**When to verify:**
151-
- After updating the `duroxide-pg-opt` submodule to a new commit
152-
- When contributing changes to pg_durable
153-
- CI automatically verifies on every pull request
154-
155138
## Documentation
156139

157140
- [User Guide](USER_GUIDE.md) — Complete usage guide with examples

docs/extension_lifecycle.md

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -93,39 +93,19 @@ fn get_duroxide_client() -> Result<&'static Client, String> {
9393

9494
## Architecture
9595

96-
### 1. Extension-Managed Schema *and* DDL (implemented)
96+
### 1. Extension-Managed Schema, BGW-Managed DDL (implemented)
9797

98-
**Change:** pg_durable ships the Duroxide provider schema DDL as extension SQL, executed directly by PostgreSQL during `CREATE EXTENSION pg_durable`.
98+
`CREATE EXTENSION pg_durable` creates the `df` schema (tables, functions, operators, RLS policies) and an empty `duroxide` schema — both as extension-owned objects. The `duroxide` schema is intentionally created without `IF NOT EXISTS`: if a `duroxide` schema already exists, installation fails immediately, preventing schema-squatting.
9999

100-
This is the PostgreSQL best-practice approach for extension-owned objects:
100+
The duroxide provider tables, functions, indexes, and triggers are **not** created by extension SQL. Instead, the background worker (BGW) populates the `duroxide` schema at startup via `MigrationPolicy::ApplyAll` (see section 2). This decouples the duroxide engine schema from the extension lifecycle:
101101

102-
- Objects created by the extension SQL scripts are registered as **extension members** (dependency type `e`).
103-
- `DROP EXTENSION pg_durable` reliably removes the schema + objects (subject to Postgres semantics; `CASCADE` may be required because the schema is non-empty).
104-
- `pg_dump`/`pg_restore` behavior is more predictable because the DDL is part of the extension lifecycle rather than “out-of-band”.
102+
- Duroxide-pg-opt upgrades require no changes to extension SQL or upgrade scripts — the BGW applies new migrations automatically.
103+
- The duroxide schema can evolve independently of pg_durable releases.
104+
- Swapping the duroxide provider only requires changes to BGW initialization code, not extension DDL.
105105

106-
#### How we do it (the “migration SQL hand-over”)
106+
Because the BGW creates duroxide objects outside the extension transaction, they are not registered as extension members. The `duroxide` schema itself remains extension-owned. This means `DROP EXTENSION pg_durable CASCADE` is always required — `CASCADE` drops the extension-owned schema, which cascades to the non-owned objects inside it.
107107

108-
We keep an audited, ordered copy of the upstream migration SQL inside this repo:
109-
110-
- `sql/duroxide_upstream/0001_*.sql``0005_*.sql` (verbatim copies)
111-
- `scripts/gen-duroxide-install-sql.sh` generates a combined `sql/duroxide_install.sql`
112-
- `scripts/verify-duroxide-migrations.sh` checks that:
113-
- our copies match `duroxide-pg-opt/migrations/`
114-
- the generated combined install SQL matches what’s checked in
115-
116-
The generated install SQL sets `search_path` to `duroxide` for the migration DDL, then resets it to `@extschema@` at the end so that subsequent extension SQL blocks (operators, etc.) resolve to the correct schema.
117-
118-
We include `sql/duroxide_install.sql` as part of the extension install SQL via `extension_sql_file!`.
119-
120-
#### Why we avoid “out-of-band” DDL
121-
122-
We previously considered (and prototyped) applying the schema DDL via Rust code.
123-
Two variants are tempting but both lose the extension ownership model:
124-
125-
1. **Separate-session migrations** (opening a new SQL connection and running DDL) create objects that are not extension members.
126-
2. **SPI from a UDF during `CREATE EXTENSION`** can create the objects, but they still are not reliably registered as extension members.
127-
128-
Given those trade-offs, running the DDL as extension SQL is the clearest, most PostgreSQL-native approach.
108+
See [bgw-applies-migrations.md](bgw-applies-migrations.md) for the full design.
129109

130110
### 2. Background Worker: `MigrationPolicy::ApplyAll`
131111

0 commit comments

Comments
 (0)