ISSUE DESCRIPTION orm.migrator.up() rewrites snapshot incorrectly Describe the bug When…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /mikro-orm, current file: none) bash-$
- Assistant
I’ll inspect the repository structure and migrator/snapshot code, identify how
up()discovers and persists snapshots, then reproduce with the relevant tests or a focused script. I’ll make the smallest source change, run affected tests, review the diff, and only then submit. - Assistant
rgis unavailable, so I’ll usegrep/find. The working tree is clean. I’m narrowing this to the schema generator, migration snapshot serialization, and SQLite-specific metadata handling. - Assistant
The repository already contains a broad stabilization change for the same class of bug, including SQLite round-trip tests. I’ll run those tests first; if they pass, I’ll inspect the exact snapshot differences produced by a realistic non-blank migration, since the existing tests mostly use blank SQL and may miss metadata fields that the reproduction exposes.
- Assistant
I was able to fetch the linked reproduction. It isolates the issue: the entity has a table column comment, the generated SQLite migration cannot encode that comment, and
up()introspects SQLite and rewrites the snapshot with the comment removed. I’ll preserve metadata comments when introspection cannot return them, while retaining actual database values when introspection does provide one. This keeps the current “snapshot reflects the migrated database” behavior without losing unsupported metadata. - Assistant
The fix is implemented and type-checks cleanly. The affected SQLite migration suite passes all 24 tests, and the diff has no whitespace errors. The preservation is deliberately conditional: target metadata is only used for missing comments, so real comments returned by database introspection are not overwritten. I’ll now review status and submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-lunaCompare side by side →