orm.migrator.up() rewrites snapshot incorrectly Describe the bug When we run…
- User
orm.migrator.up()rewrites snapshot incorrectlyDescribe the bug
When we run
orm.migrator.up(), the snapshot changes and a bunch of stuff in the snapshot is wrong and we have to revert the changes.Reproduction
https://github.com/zachkirsch/mikro-orm-migrate-snapshot-repro
What driver are you using?
@mikro-orm/sqlite
MikroORM version
7.1.2-dev.10
Node.js version
v24.0.1
Operating system
macOS
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord.
- The provided reproduction is a minimal reproducible example of the bug.
Interface
No new interfaces are introduced.
- Assistant
I’ll trace the migration-up snapshot update path, reproduce it with existing fixtures or a focused regression test, then patch and run the relevant test suite.
- Assistant
rgisn’t installed here, so I’m switching to repository-native search tools and narrowing the investigation to the migrations package and SQLite tests. - Assistant
The root cause is that
up()re-introspects the live database and replaces the migration snapshot, even though that snapshot was already authored from metadata duringcreate(). I’m changingup()to preserve that file;down()still refreshes it because rollback intentionally moves the schema behind the stored target. - Assistant
The implementation and regression assertions are in place. The first test invocation used a Jest-only flag that this Vitest repository rejects; I’m rerunning with the project’s supported command, then I’ll type-check/format the touched code.
- Assistant
The SQLite regression suite is green (24 tests). I also preserved transaction-aware introspection for the remaining
down()path, so rollback snapshots still observe schema changes made inside an external transaction. I’m doing the final verification now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.