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 snapshot update path, reproduce the failure with existing fixtures or a focused regression test, then patch and run the relevant test suite.
- Assistant
rgisn’t installed in this checkout, so I’m switching to targetedfind/grepsearches. The worktree is currently clean. - Assistant
The fault is in
runMigrations: after every successfulup, it replaces the migration-generation snapshot (the entity target schema) with a database-introspected schema. That is both lossy on SQLite and logically wrong when only some pending migrations are applied. I’m narrowing snapshot refreshes todown, where the target genuinely needs to move backward. - Assistant
The focused SQLite migration suite is running. Its shared test bootstrap also initializes the local MongoDB test binary; that setup has completed, and I’m waiting on the actual migration assertions now.
- Assistant
The SQLite regression suite passes all 24 tests, and targeted type-aware linting is clean. I’ve also updated the PostgreSQL transaction regression so it now verifies that
up()preserves the exact snapshot instead of merely checking that a file exists. - Assistant
The migrations package compiles successfully. The PostgreSQL regression cannot execute in this environment because no server is listening on
127.0.0.1:5432; collection reached the suite, then failed during its database setup before any test ran.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.