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.
Interface
No new interfaces are introduced.
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 start by exploring the repository structure and understanding the migrator/snapshot issue.
- Assistant
Let me examine the migrator package and search for snapshot-related code.
- Assistant
Let me look at Migrator.ts and search for snapshot related code.
- Assistant
rg is not available, let me use grep.
- Assistant
Let me open Migrator's snapshot logic and related schema serialization.
- Assistant
Let me continue reading the Migrator.ts file, especially the parts about storing the snapshot.
- Assistant
I'll inspect storeCurrentSchema and how DatabaseSchema serializes to understand the incorrect rewrite.
- Assistant
I'll search git history and related tests for snapshot rewrite issues.
- Assistant
I'll inspect recent snapshot serialization changes and how DatabaseSchema is serialized.
- Assistant
I'll review the previous snapshot stabilization fix and scan for related open issues.
- Assistant
I'll try to clone the reproduction repository to understand the exact bug.
- Assistant
Good, cloned successfully. Let me examine the reproduction.
- Assistant
Let me read all the source files in the reproduction.
- Assistant
I'll check how SQLite handles column comments and how the schema helper deals with them.
- Assistant
Let me inspect SQLite's schema helper and how create SQL handles comments.
- Assistant
I'll check why runMigrations rewrites the snapshot and how comparator handles unsupported comments.
- Assistant
I'll check how comment diffs interact with SQLite and SchemaHelper's skipping logic.
- Assistant
I'll check how SQLite handles change-column-comment SQL.
- Assistant
Let me read getChangeColumnCommentSQL and appendComments
- Assistant
Let me look at getChangeColumnCommentSQL
- Assistant
I'll check SchemaComparator for ignore options around comments and review recent snapshot tests.
- Assistant
I'll inspect how SQLite retrieves table and column comments during introspection.
- Assistant
Let me look at getListTablesSQL and getColumns for SQLite.
- Assistant
I'll open DatabaseTable.toJSON to see how comments are serialized.
- Assistant
I'll check whether Platform exposes APIs for comment support.
- Assistant
I'll set up a local reproduction against this repository to confirm the bug.
- Assistant
Packages need to be built. Let me check if dist exists.
- Assistant
I'll check how tests import packages and whether a build is needed.
- Assistant
I'll write a temporary reproduction test and run it with vitest.
- Assistant
I'll check helpers and Pattern in Migrator.sqlite tests for how to structure —the temp recreation.
- Assistant
bootstrap.js exports TEMP_DIR - let me check
- Assistant
I'll place a temporary test in tests/issues and run it.
- Assistant
Now run the test with vitest.
- Assistant
The test timed out—I'll check vitest global setup and try a more targeted run.
- Assistant
I'll try running vitest while skipping the global setup that connects to databases.
- Assistant
Something is hanging without output—I'll try a simpler approach.
- Assistant
Yarn waited for interactive corepack input — I'll configure that and rerun.
- Assistant
I'll check whether a comment-only diff produces a non-empty migration on SQLite.
- Assistant
I'll inspect SchemaComparator/helper paths that trigger comment-only rebuilds on SQLite.
- Assistant
Let me look at lines around 711 for when SQLite decides to rebuild.
- Assistant
I'll check which platforms support comments and how table comments are handled.
- Assistant
I'll inspect the SchemaComparator constructor and how it accesses the platform.
- Assistant
I'll check whether MSSQL and other platforms support schema comments.
- Assistant
MSSQL and我市 Oracle support via appendComments. MySQL via column DDL. PostgreSQL too. SQLite is the outlier.
- Assistant
I'll inspect base create-table helpers regarding comments and Platform defaults around line 839.
- Assistant
I'll look at table-level comment handling and SqlitePlatform.
- Assistant
Let me also check table comment comparison location а in SchemaComparator.
- Assistant
I'll check DatabaseSchema.toJSON and then apply the fix.
- Assistant
Implementing platform flags andwiring them into snapshot serialization and schema comparison.
- Assistant
Need to open the file first at that line.
- Assistant
Now I can apply the replace.
- Assistant
Next I'll override those methods on SqlitePlatform.
- Assistant
I'll add the overrides after usesEnumCheckConstraints.
- Assistant
Now I'll update DatabaseTable.toJSON and SchemaComparator.
- Assistant
I'll update the comment fields in toJSON.
- Assistant
Now replace the comment lines.
- Assistant
Now update table-level comment.
- Assistant
Need to navigate there first.
- Assistant
Now replace
- Assistant
Now I'll update SchemaComparator for table and column comments.
- Assistant
Update table and column commentτσ checks.
- Assistant
Now column comment in diffColumn
- Assistant
Replace column comment check.
- Assistant
I'll also check routine comments for completeness, and views.
- Assistant
I'll check whether libsql/node-sqlite define their own platforms.
- Assistant
I'll update the temp test and run it.
- Assistant
The test passed. I'll run Migrator.sqlite and other snapshot-related tests.
- Assistant
I'll check for SQLite comment-related tests and confirm legacy snapshot behavior.
- Assistant
There's also GH7185 about multiline comments - I'll check for an SQLite variant.
- Assistant
Looking at GH7185 - it uses multiple drivers. Let me see which.
- Assistant
I'll run SQLite schema-generator tests that might involve comments.
- Assistant
Timed out waiting for DBs — I'll filter to SQLite only.
- Assistant
I'll adjust the filter path.
- Assistant
I'll remove the temporary test file and review the final diff.
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
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →