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 migrator’s snapshot write path, reproduce the SQLite regression with focused tests, then patch and verify it locally.
- Assistant
The suspect path is confirmed: after applying migrations,
up()replaces the metadata-derived snapshot with a fresh database-introspection snapshot. I’m checking which fields SQLite cannot round-trip and whether the migration tracking table is also leaking into the file. - Assistant
The focused SQLite suite already preserves the snapshot’s JSON shape, including the previously divergent column/index fields. I’m tightening the write itself now so an equivalent post-migration schema does not rewrite the snapshot file at all, while genuine schema changes still update it.
- Assistant
The regression test now verifies both requirements: the snapshot content remains identical after
up(), and the filesystem write is skipped entirely. The focused migration suite passes; I’m doing the final formatting/type checks and reviewing the diff for edge cases. - Assistant
Formatting is clean. The repository-wide TypeScript check exceeded Node’s 4 GB heap before reporting diagnostics, so I’m switching to the migrations package’s scoped build/check to validate the touched code without that resource bottleneck.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.