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
Let me check how SQLite handles comments in introspection, and what platform capability flags exist.
- Assistant
Issue #7798 confirmed. Now let me write the failing test first, modeled on GH7796:
- Assistant
Let me check whether plain
schema:updateon sqlite already churns for commented columns (to understand scope): - Assistant
All sqlite-family drivers share
SqlitePlatform. Now let me look at the pieces I need —getTargetSchema,DatabaseSchema.getTable: - Assistant
Now implementing the fix. Let me view the relevant spots:
- Assistant
Now the SchemaComparator — guard both table and column comment diffs:
- Assistant
Test passes. Let me verify the
schema:updatechurn is also fixed, then clean up the scratch file: - Assistant
Both fixed. Remove the scratch file and add a second test covering the comparator guard (the
schema:updatechurn path): - Assistant
Both pass. Now run the wider validation — first check for existing tests that may rely on the old comment-diff behavior on sqlite:
- Assistant
While that runs, let me review the final diff:
- Assistant
One fragile spot: when
table.schemais undefined, the lookup key becomes"undefined.account". Make the qualified lookup conditional: - Assistant
All 674 sqlite tests pass — but I edited
Migrator.tsafter that run started. Re-validate: build, lint, and rerun sqlite + libsql tests: - Assistant
Now run the broader DB-independent suites that use sqlite without "sqlite" in the filename (issues + schema-generator):
- Assistant
While that runs, let me double-check no other platform overrides or callers conflict:
- Assistant
Consistent. Waiting for the background suite to finish now.
- Assistant
No output yet — the suite is still in its transform phase. I'll report back when it completes.
- Assistant
The multi-DB noise makes that run unusable. Cleaner: run only the driver-agnostic test files (those not importing external DB drivers):
- Assistant
While waiting, scan the earlier partial log for any failure that isn't a connection/timeout:
- Assistant
Thread exhaustion — likely zombie vitest workers from earlier runs. Clean up and rerun with capped workers:
- Assistant
Validation complete. The only 2 failing files are
GH5591.test.ts(postgres/mysql variants) andSchemaGenerator.oracle.test.ts— both fail on database connection errors (no docker in this environment), unrelated to the change. All 335 other files (608 tests) pass.Summary
Bug (#7798):
migrator.up()rewrites from database introspection, but SQLite cannot persist table/column comments — so every comment in the snapshot flipped to , dirtying the committed file. The same root cause also made perpetually generate destructive temp-table rebuilds for any commented entity on sqlite (comment-only changes route through ). - Assistant
That's the earlier monitor timing out — its target run was already superseded and fully accounted for (the rerun completed: 335/337 files passed, with the 2 failures being external-DB connection errors). No re-arm needed; the task is complete as summarized above.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.