#24184 closed Bug (fixed)
Migrate auto-fake behavior is not safe
Reported by: | Carl Meyer | Owned by: | Markus Holtermann |
---|---|---|---|
Component: | Migrations | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Markus Holtermann | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently, manage.py migrate
will auto-fake-apply initial migrations if it sees that the tables already exist, but it doesn't do any checking that the schema of those tables actually matches the schema that the migration would have created. And our documentation doesn't call out the importance of making sure that your existing schema matches the models you used to generate the initial migrations.
In an ideal world, we might keep the current behavior and automatically verify a full schema match before auto-faking, but I doubt that's feasible and in any case would be a major new feature.
Short of that, I think the unsafe auto-fake behavior should not be the default; it should require a flag like --fake-if-exists
or something (needs bikeshedding) to turn it on. Wherever that flag is documented/demonstrated in the docs (e.g. in the https://docs.djangoproject.com/en/1.7/topics/migrations/#upgrading-from-south upgrade-from-South docs), we should be very clear that it is only safe to use if you are sure that your schema is properly up-to-date with your models used to generate your initial migration.
(This ticket was motivated by #24178.)
Change History (10)
comment:1 by , 10 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 10 years ago
Has patch: | set |
---|---|
Needs documentation: | set |
comment:4 by , 10 years ago
As discussed in IRC, I don't think we should backport this to 1.7 (much as I'd like to), since it's a backwards-incompatible change in user-facing behavior. We'll just have to put a warning in the docs for 1.7.
comment:6 by , 10 years ago
Reviewed PR, looks good to me, just needs some doc tweaks and to be merged up with latest master.
comment:7 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:8 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Initial PR: https://github.com/django/django/pull/3967
Should that be backported to 1.7 given that it's the first version you upgrade to when you move away from South.