[Django] #32834: DEFAULT_AUTO_FIELD should allow for diable migration for existing models

20 views
Skip to first unread message

Django

unread,
Jun 10, 2021, 3:38:33 AM6/10/21
to django-...@googlegroups.com
#32834: DEFAULT_AUTO_FIELD should allow for diable migration for existing models
-------------------------------------+-------------------------------------
Reporter: qiu-lijie | Owner: nobody
Type: New | Status: new
feature |
Component: | Version: 3.2
Migrations |
Severity: Normal | Keywords: DEFAULT_AUTO_FIELD
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32834>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 10, 2021, 4:49:52 AM6/10/21
to django-...@googlegroups.com
#32834: DEFAULT_AUTO_FIELD should allow for diable migration for existing models
------------------------------------+--------------------------------------
Reporter: qiu-lijie | Owner: nobody
Type: New feature | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: DEFAULT_AUTO_FIELD | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

> While I understand Django wants to move away AutoField and towards
BigAutoField for pk

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.

> the current behaviour will make migrations for third-party apps, which
is not desirable

3rd-party apps can set `AppConfig.default_auto_field` to the
`'django.db.models.AutoField'` to avoid migrations, you can also set
`DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'` in your project.

We allowed customization at all levels (project, app, model) see
[https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-
auto-created-primary-keys release notes]. Also it looks that
[https://pypi.org/project/django-allauth/ django-allauth] and
[https://pypi.org/project/django-cities-light/ django-cities-light] don't
officially support Django > 3.2, you can try to report this in their
bugtrackers.

--
Ticket URL: <https://code.djangoproject.com/ticket/32834#comment:1>

Reply all
Reply to author
Forward
0 new messages