Repository navigation
Conversation
|
@onmax is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
|
Drafted by an AI agent (Amp) on behalf of @atinux, who reviewed it before posting. Thanks @onmax, making PostgreSQL migrations atomic and serialized is a real fix. Today a statement that fails halfway leaves the database half-migrated, and two instances booting at once can run the same migration twice. The PGlite tests checking real database state are great too. A few things before this can land: 1. Atomicity changes behavior for every PostgreSQL user, not only those setting
I think this needs a changelog note and docs, and maybe a way to opt out. 2. The CREATE SCHEMA "auth";
--> statement-breakpoint
CREATE TABLE "auth"."sessions" (
"token" text PRIMARY KEY NOT NULL
);So the app's own first migration would error with "schema already exists". Users don't hand-write these files, so asking for
3. Moving history implicitly feels risky. 4. Scope.
Would you be open to splitting this into two PRs, rebased on
Smaller notes:
|
Each PostgreSQL migration file now runs in one transaction with its history row, under an advisory lock that also guards history table creation. Files starting with `-- nuxthub:no-transaction` run statement by statement on a reserved connection under a session-level lock, for statements such as CREATE INDEX CONCURRENTLY. Migration names are passed as parameters when recording history, including in `db mark-as-migrated` and `db squash`.
783861d to
84444ee
Compare
|
thanks for the review! split it: this PR is now only the atomic migrations, rebased on main, with the transaction limits documented and a |
|
Drafted by an AI agent (Amp) on behalf of @atinux, who reviewed it before posting. Thanks for splitting it, this reads much better. The A few notes: 1. This is a breaking change for some PostgreSQL users. 2. Docs advice for existing files. 3. Question about Looking forward to the |
on postgres, a migration that fails halfway leaves the db half-migrated, and two instances booting at once can apply the same migration twice.
this runs each postgres migration file and its
_hub_migrationsrow in one transaction, under an advisory lock, so each file is applied once and fully or not at all. mysql and sqlite don't change. statements that can't run in a transaction (CREATE INDEX CONCURRENTLY,VACUUM,BEGIN/COMMIT) now fail, unless the file starts with-- nuxthub:no-transaction. this is documented, and I think it is worth a line in the release notes. a new enum value has to be used in the next file. migration names are now passed as parameters in the runner,mark-as-migratedandsquash.