Make all migrations idempotent #55
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/idempotent-migrations"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
First PR of the refactor series from the 2026-06 code review (findings #3/#12).
The migration version bump lands in the core
dbversionstable while the DDL lands inext_libra— the two writes are not atomic. A failed bump re-runs the whole migration on next boot; a bare CREATE/ALTER/INSERT then crashes the extension until manual dbversions surgery.Changes:
CREATE TABLE/CREATE INDEX→IF NOT EXISTSthroughoutALTER TABLE ADD COLUMN→_alter_add_column_safe(same swallow pattern as the events/withdraw fork migrations)ON CONFLICT (name) DO NOTHINGTests: new
tests/test_migrations.pyruns the chain twice against a fresh SQLite DB (full-chain rerun + per-migration rerun). Both tests were verified to FAIL against the previous migrations and pass now. Full suite: 153 passed, 3 skipped, 8 xfailed.🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.