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, packages are linked in node_modules. Let's place the script inside repo root and run with node.
Assistant
No python3; use sed/replace command instead.
Assistant
Good, let's mimic this for sqlite driver using the same entity list minus mysql-only stuff, using ReflectMetadataProvider.
Assistant
Need to remove Dummy2 from the first import list to avoid duplicate import.
Assistant
Now let's build a migrator repro with a trigger entity.
Assistant
Confirmed:
setTriggerswas never called ingetSchemaFromSnapshot. This is a genuine bug — let's fix it, and also double check for similar oversight regardingcolumnsreconstruction (e.g., missingextra/defaultConstraintrestoring, but those come through spread already). Let's view the exact code section again.Assistant
Now let's add the missing trigger restoration.
Assistant
Now let's re-run the trigger repro test to confirm the fix works.
Assistant
All fields are now covered: columns, indexes, checks, triggers, foreignKeys, comment, nativeEnums, schema, name. Let's run the full existing migrations test suite to confirm nothing broke, then clean up.
Assistant
Confirmed these are pre-existing environment failures (mysql not available) unrelated to our change. Let's restore our fix.
Assistant
Now let's run the sqlite-specific migrations tests (the ones that pass in this environment) to confirm no regressions with the fix.
Assistant
All these failures are pre-existing (mysql unreachable), unrelated to our change. Sqlite tests and trigger tests pass (27 passed). Let's run broader schema-generator sqlite tests too, plus check full repo test suite for the sql/migrations packages to be safe.
Assistant
No sqlite test failures. Good. Let's also run the broader migrations-related tests and issues tests to be thorough.
Assistant
That's unrelated (Postgres connection required, name is coincidentally "sqlite" but the test file is for postgres). Not related to our fix. Let's check overall test summary for the whole suite excluding db-dependent failures, just confirm the diff itself is minimal and correct.
Assistant
Type-checks clean. Let's view the final diff once more and run the full sqlite migrations test suite one more time to be certain.
Assistant
All tests pass. Now let's go over the checklist.
Assistant
Assistant
The repository is clean apart from the intended fix. I'm confident in this change and will submit it now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.