From b82c1db73524a7367301ba1d2469cdf981e00662 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 10 Feb 2023 08:21:03 +1100 Subject: [PATCH] mailman: set web auto field size to "AutoField" It seems that in django>=3.2 the assumption that an implicit primary key would be an AutoField changed to becoming a BigAutoField (64-bit). django warns now Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'. HINT: Configure the DEFAULT_AUTO_FIELD setting or the UsersConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'. I think we took the hint to add this as BigAutoField. However, it seems that we probably made the db tables with the smaller field. When we now start the web container we are told that the models don't match. When I ran "makemigrations" it made a bunch of migration files to update to BigAutoField id's. Because the migrations are made during the installation (I'm guessing), the container doesn't have this migration included with it. I think to avoid getting into a mess of migrations, we should just leave this as is. If upstream decides to set this on an application-basis I think that will override this, and we will get a migration as part of the general installation and that will work fine. The problem is just that we're setting it "outside" the installation. Change-Id: I1679631cd4f7ea14563aab07ad4450c35aa90fd8 --- playbooks/roles/mailman3/files/web-settings_local.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/playbooks/roles/mailman3/files/web-settings_local.py b/playbooks/roles/mailman3/files/web-settings_local.py index a755892a8a..05ad1eeea7 100644 --- a/playbooks/roles/mailman3/files/web-settings_local.py +++ b/playbooks/roles/mailman3/files/web-settings_local.py @@ -18,4 +18,8 @@ MAILMAN_WEB_SOCIAL_AUTH = [] FILTER_VHOST = True -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +# See +# https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-auto-created-primary-keys +# We set this to AutoField to avoid unwanted migrations as we've +# already created the models with the smaller field size. +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'