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
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).
Copy file name to clipboardExpand all lines: README.md
-17Lines changed: 0 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,23 +135,6 @@ Complex integration tests with Docker:
135
135
136
136
See [tests/e2e/](tests/e2e/) for details.
137
137
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
-
155
138
## Documentation
156
139
157
140
-[User Guide](USER_GUIDE.md) — Complete usage guide with examples
**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.
99
99
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:
101
101
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.
105
105
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.
107
107
108
-
We keep an audited, ordered copy of the upstream migration SQL inside this repo:
- 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.
0 commit comments