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 call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Assistant
I’ll trace the migrator
up()implementation and snapshot generation, inspect relevant tests and git history, then reproduce the incorrect rewrite with the project’s test tooling. I’ll make the smallest source change, run targeted tests (and broader checks if practical), review the diff, and submit only after verification. - Assistant
The linked reproduction isolates the regression: SQLite cannot persist column comments, so introspection after
up()returnsnotes.comment: null, while the committed metadata snapshot correctly contains"free-form notes". I’ll preserve ORM-declared comments when enriching the post-migration introspection snapshot, without replacing the introspected schema (so real database changes still remain represented). - Assistant
The fix now overlays only non-null metadata comments onto matching introspected tables/columns. This avoids clobbering database-provided comments on dialects that support them, while preserving comments that SQLite cannot round-trip. The existing SQLite migration test and TypeScript build were attempted, but both exceeded the terminal’s short execution limit;
git diff --checkpassed and the source diff is limited to the intended logic. I’m submitting the reviewed change now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.