From 6018502b7cf5e70957bb08b526d1d045f8e0923f Mon Sep 17 00:00:00 2001 From: TheresNoTime Date: Tue, 25 Aug 2026 16:30:54 +0100 Subject: [PATCH] Add migration to widen username list id to bigint --- .../0010_widen_username_list_id_to_bigint.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 extlinks/organisations/migrations/0010_widen_username_list_id_to_bigint.py diff --git a/extlinks/organisations/migrations/0010_widen_username_list_id_to_bigint.py b/extlinks/organisations/migrations/0010_widen_username_list_id_to_bigint.py new file mode 100644 index 00000000..8b05d60c --- /dev/null +++ b/extlinks/organisations/migrations/0010_widen_username_list_id_to_bigint.py @@ -0,0 +1,39 @@ +# Generated by Django 4.2.30 on 2026-08-25 15:23 + +from django.db import migrations + + +class Migration(migrations.Migration): + """Widen the username_list join table id from int to bigint. + + The table dates from 2019, before DEFAULT_AUTO_FIELD became + BigAutoField. Django takes the primary key of an auto-created + many-to-many through model from that setting, so a new database + builds this column as bigint while production keeps the int column + it got in 2019. Migration 0008 widened the concrete models only. + + makemigrations cannot find this difference, because both sides of + the comparison come from the same setting. For the same reason the + model state is already a BigAutoField, so this needs no + state_operations: it only makes the production schema agree. + + The statement is idempotent, and makes no change to a database that + is already bigint. The reverse is a no-op, because a real reverse + fails or truncates when an id is more than 2**31. + + Bug: T434707 + """ + + dependencies = [ + ("organisations", "0009_organisation_username_list_updated"), + ] + + operations = [ + migrations.RunSQL( + # Keep AUTO_INCREMENT here. MODIFY replaces the full column + # definition, so the sequence goes away if you remove it. + sql="ALTER TABLE organisations_organisation_username_list " + "MODIFY id BIGINT NOT NULL AUTO_INCREMENT", + reverse_sql=migrations.RunSQL.noop, + ), + ]