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
{{ message }}
Repository navigation
migrate --stop-before commits earlier sets before rejecting an already-applied target #870
When sqlite-utils migrate loads multiple migration sets, an already-applied --stop-before target in a later set causes an error after earlier sets have committed pending migrations. The CLI validates that targets exist before applying anything, but the already-applied check happens inside each set's Migrations.apply(), so it comes too late for earlier sets.
Reproduction (Python 3.12.12, sqlite-utils 4.2.1 at 85b1be10c81d9dd3567e36faf8dd411e4a8789bd): save this as repro.py and run python repro.py in an environment with sqlite-utils installed.
Exit code: 1
Error: Cannot stop before migration first in set 'b' - already been applied
Earlier pending migration was applied: True
Recorded migrations: [('b', 'first'), ('a', 'first')]
Expected: the same error, but table a should not exist and only b:first should be recorded. The failed command should leave a:first pending.
The validation in cli.py:migrate could check already-applied targets across all loaded sets before entering the application loop. The current check in Migrations.apply() protects only that individual set.
The reproduction gives the same result on two fresh databases. The existing migration tests pass (31 passed across tests/test_migrations.py and tests/test_cli_migrate.py); the applied-target CLI test currently covers one set.
Activity