Opened 4 years ago
Closed 4 years ago
#32834 closed New feature (invalid)
DEFAULT_AUTO_FIELD should allow for diable migration for existing models
Reported by: | qiu-lijie | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 3.2 |
Severity: | Normal | Keywords: | DEFAULT_AUTO_FIELD |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
DEFAULT_AUTO_FIELD new in 3.2 will change existing models' pk to BigAutoField, as BigAutoField is the default for new projects. I believe there should be an option to disable this behaviour, i.e., not migrate existing models to BigAutoField. While I understand Django wants to move away AutoField and towards BigAutoField for pk, the current behaviour will make migrations for third-party apps, which is not desirable. Ideally, all third-party apps would also migrate their own models to use BigAutoField, but we all know that some don't get maintained as much, see examples below.
Migrations for 'account': /usr/local/lib/python3.8/site-packages/allauth/account/migrations/0003_auto_20210610_0705.py - Alter field id on emailaddress - Alter field id on emailconfirmation Migrations for 'cities_light': /usr/local/lib/python3.8/site-packages/cities_light/migrations/0011_auto_20210610_0705.py - Alter field id on city - Alter field id on country - Alter field id on region - Alter field id on subregion
First of all I would like to ensure you that this will not happen in the nearest future (maybe never). I can not imagine that we would change that before dropping support for all versions prior to 3.2.
3rd-party apps can set
AppConfig.default_auto_field
to the'django.db.models.AutoField'
to avoid migrations, you can also setDEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
in your project.We allowed customization at all levels (project, app, model) see release notes. Also it looks that django-allauth and django-cities-light don't officially support Django > 3.2, you can try to report this in their bugtrackers.