Skip to content

Run migrations in a transaction - #4164

Merged
finestructure merged 1 commit into
mainfrom
migrations-in-transactions
Sep 16, 2026
Merged

finestructure merged 1 commit into
mainfrom
migrations-in-transactions

Conversation

@finestructure

@finestructure finestructure commented Sep 16, 2026

Copy link
Copy Markdown
Member

Rebased branch, supersedes #4135

FluentKit's migrator calls `prepare` and then writes the `migrations`
row as two separate operations with no enclosing transaction. A
multi-step migration that throws part way commits the steps that already
succeeded *and* records nothing, so the re-run fails on "column already
exists" against a half-changed schema.

Add all migrations to an array, and then run each one through a
`TransactionalMigration` to force them to run as a transaction.

Some migrations (036, 037, 044) already run in transactions, but nesting
s safe: Postgres has no nested transactions and FluentKit makes
the inner call a passthrough.

# Conflicts:
#	Sources/App/configure.swift
@finestructure
finestructure merged commit 23d4e15 into main Sep 16, 2026
4 checks passed
@finestructure
finestructure deleted the migrations-in-transactions branch September 16, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants