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 update path, reproduce the mutation with the local tests, then patch and add a focused regression test.
- Assistant
The relevant path rewrites the file from live database introspection after a migration, while migration creation writes it from metadata. I found an existing stability test around that boundary; I’m running it first to see which representation still diverges.
- Assistant
The canonicalized schemas now compare equal in the focused test. I’m tightening the behavior at the file boundary too: if
up()produces the exact same canonical snapshot, it should leave the file untouched, and the regression will compare the serialized bytes rather than parsed objects so ordering-only churn is caught. - Assistant
The regression now verifies both outcomes: the snapshot bytes remain identical and no write is attempted for the no-op update. The focused SQLite suite passes; I’m doing the final static/diff checks now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.