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 SQLite corruption with a focused test, then patch and run the relevant migration test suite.
- Assistant
rgisn’t installed in this checkout, so I’m usingfind/grepfor the same repository inspection. I’m also checking local contribution instructions and existing worktree changes before editing. - Assistant
The repository history contains an earlier snapshot-stability fix and regression test, so I’m validating whether this report is already partially covered or exposes a remaining SQLite shape mismatch. The key comparison is metadata-generated JSON versus the post-
up()introspected JSON. - Assistant
The normalized schemas are already byte-identical in the focused reproduction. I found one remaining source of the reported behavior:
up()still writes the identical JSON back to disk. I’m changing snapshot persistence to skip an unchanged payload and tightening the regression test to verify both byte stability and no filesystem rewrite. - Assistant
The focused SQLite migration suite passes all 24 tests. The regression now confirms that
up()leaves an already-correct snapshot byte-for-byte untouched and does not invoke the write operation. I’m running static checks on the two changed files next. - Assistant
Static checks are clean. A broader migrator suite cannot start because its MySQL fixture expects a server on
127.0.0.1:3308; all 46 tests were skipped after connection refusal, so this is an environment dependency rather than a code failure. I’ll finish with a package-level TypeScript build check that does not require the database.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.