You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migrations do not detect a change on the database dialect #5235
When a project is created using one database dialect (SQLite for example) and later changed to other (Postgres), the next call to a create-migration will detect no changes unless the models have changed. This is wrong in two ways:
If the models have changed, no existing database will ever be able to migrate from the last version because its SQL targets a different dialect.
If the models have not changed, we need a new SQL that targets the current database dialect to be able to start the server, or it will face runtime errors.
The correct solution is to detect that the dialect have changed and ask for --force to completely wipe the existing migrations and create a new one.
@nicowalter256 Not yet. The design that needs thinking for this issue is the best way to track the previous dialect version. A possible alternative is a formatted comment at the top of the definition.sql and migration.sql. Using the *.json files is not ideal because they are dialect-agnostic - and loaded separately from the *.sql files. Adding another file is also not a good idea because each migration folder already has many files. Feel free to explore/propose other options. I'll only suggest we agree on the direction here before you jump to implement.
Hi, @marcelomendoncasoares
I've reviewed the issue. The migrations rely only on model snapshots, which are dialect-agnostic, so when we switch databases, it silently fails.
We can add a small, machine-readable header inside each migration SQL file that records the dialect.
Then, before creating or applying migrations, we check that header against the current config.
If they are different, the system stops and asks for a force flag before resetting the migrations. This way, we prevent accidental mismatches.
Let me know if you think this is okay.
Activity
nicowalter256 commentedon Jun 19, 2026
is this fixed?
marcelomendoncasoares commentedon Jun 20, 2026
@nicowalter256 Not yet. The design that needs thinking for this issue is the best way to track the previous dialect version. A possible alternative is a formatted comment at the top of the
definition.sqlandmigration.sql. Using the*.jsonfiles is not ideal because they are dialect-agnostic - and loaded separately from the*.sqlfiles. Adding another file is also not a good idea because each migration folder already has many files. Feel free to explore/propose other options. I'll only suggest we agree on the direction here before you jump to implement.nicowalter256 commentedon Jun 20, 2026
wanna contribute to some other issue. any suggestions
abdulawalarif commentedon Jul 3, 2026
Hi, @marcelomendoncasoares
I've reviewed the issue. The migrations rely only on model snapshots, which are dialect-agnostic, so when we switch databases, it silently fails.
We can add a small, machine-readable header inside each migration SQL file that records the dialect.
Then, before creating or applying migrations, we check that header against the current config.
If they are different, the system stops and asks for a force flag before resetting the migrations. This way, we prevent accidental mismatches.
Let me know if you think this is okay.
abdulawalarif commentedon Jul 5, 2026
Hi, @marcelomendoncasoares @SandPod @dkbast , I've reproduced this issue and would like to start working on a fix.. Can anyone please assign this to me?