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 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
Good, so tests use ts sources directly (aliasing packages). Let's write a temp test file.
Assistant
Good, DecimalType already imported. Let's view exact
initmethod lines to edit precisely.Assistant
Now let's add precision/scale recovery similarly, mirroring the regex used in
addColumnFromProperty.Assistant
Now let's edit lines 134-139 to add precision/scale recovery.
Assistant
Now snapshots are identical after create vs after up. Let's clean up temp test files and run the full migrations test suite (sqlite, mysql, postgres if available) plus schema tests to ensure no regressions.
Assistant
Now let's run broader schema-related test suites for sqlite, and any other dialects available offline (postgres/mysql might require DB connections not available). Let's check.
Assistant
Now let's check if postgres/mysql test DBs are available, and run broader test suite for sql schema package + core.
Assistant
Confirmed this failure pre-exists without my change (uses mysql presumably, connection unavailable). Not related to our fix. Good, our change is isolated and safe.
Assistant
Excellent, snapshots are identical across a broader set of features too. Let's clean up temp test files and also check checkSchema behaves correctly (no diff) after up in this broader scenario.
Assistant
Now let's run the full sqlite-related test suite (migrations, schema-generator) once more plus core tests to be thorough, and check lint/type-check.
Assistant
Let's also run lint/type checks for the sql package to ensure code style is correct.
Assistant
Lint passes. Now let's double check tsc type-check for the sql package.
Assistant
That's fine, oxlint already does type checking. The fix is minimal and well-tested. Let's view final diff once more and finish up.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.