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, tests must live under
tests/**/*.test.ts. I'll create a temporary test file there for reproduction, then delete before submitting.Assistant
Now let's apply the fix in
initDefaultValue.Assistant
There's a duplicated closing brace on line 2277. Let me fix that.
Assistant
Good, fixed. Now let's re-run the reproduction test with the object default restored.
Assistant
No diffs now, and
checkSchema()correctly returnsfalse. Let's verify the actual default value stored is sane.Assistant
Let's temporarily add printing the meta column default to the test to verify correctness.
Assistant
Now the default is correctly stringified as
'{"a":1}'in both paths. Let's also test with array default to ensure no regressions, and test plain object default for a non-JSON custom type (e.g. embedded object) if applicable. Let's also run the full existing test suite for migrations and core metadata to check no regressions.Assistant
Now let's run the broader test suite that touches MetadataDiscovery, JSON types, defaults, and schema generation to check for regressions.
Assistant
Now let's run the broader core/schema/migrations test suites.
Assistant
Good — confirmed those failures are pre-existing (no postgres/mysql servers available), unrelated to my change. Let's run only sqlite-focused tests and generic (non-vendor) tests properly.
Assistant
Identical results (25 failed | 21 passed) before and after my change — confirms these failures are pre-existing environment issues (missing DB servers), not caused by my fix. Now let's run the broader sqlite-only test suite plus core metadata tests to be thorough.
Assistant
Confirmed — that's also an environment connectivity issue (MySQL unavailable), unrelated to my change. All other failures shown are DB connectivity issues too (mysql/mariadb/postgres/mssql/oracle/mongo ports unreachable). Let's confirm counts match baseline exactly.
Assistant
Identical results (154 failed | 363 passed, 47 failed | 1127 passed | 386 skipped) before and after my change — confirms my fix introduces no regressions across the full non-vendor test suite.
Assistant
Now let's double check
Utilsis already imported in this file.Assistant
Good. Now let's run the migrator and defineEntity tests once more to confirm final state, then check for lint/typecheck.
Assistant
Lint passes. Let's also verify the full diff one final time and clean up any stray temp files.
Assistant
Clean — only the intended fix remains. Let's view the final diff once more for confirmation.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.