JeremyIf it was my project I would explicitly model the through tables.The other options are covered in the references you gave - which were news to me!CheersMike--(Unsigned mail from my phone) -------- Original message --------From: Jeremy Lainé <jeremy.la...@gmail.com> Date: 16/5/22 16:52 (GMT+10:00) To: Django users <django-users@googlegroups.com> Subject: Re: Migrating ManyToManyField to bigint? Hi Mike,Thanks for the reply. For future reference, it was pointed out to me that I missed both an explicit note in the documentation [1] and an issue tracking a potential change in the future [2].Do you have any suggestions as to the actual SQL migration which needs to be applied for postgresql on each m2m table? Specifically, is it purely a matter of altering the "id" column type, or does something need to be done to the index?Cheers,Jeremy[1] https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field[2] https://code.djangoproject.com/ticket/32674On Sunday, May 15, 2022 at 10:26:18 AM UTC+2 Mike Dewhirst wrote: On 14/05/2022 11:44 pm, Jeremy Lainé wrote: Hi! I'm currently looking at how to migrate all my models from AutoField to BigAutoField. For all the explicitly defined models the process seems pretty straightforward: change DEFAULT_AUTO_FIELD to BigAutoField generate migrations apply migrations However, when I inspect the database schema, I see that the "intermediate" tables for many-to-many relations still have a primary key of type "integer" (on postgresql). This means I'm no closer to avoiding 32bit primary key exhaustion! Does anyone know how I can address this? Not really. In my case I specify models for all my m2m intermediate tables as a matter of course. It is how I think. In my schemas, most such tables typically carry extra data about the relationships they define - therefore I want models. The bigint migration obviously worked for me. Maybe you can use manage.py to write out your m2m models so you can adjust then migrate them. settings.DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" should work for new intermediate tables. Another option is to manually adjust all your m2m PostgreSQL id fields to bigint. It is a lossless change and will never need to be reversed so it might be easier to bite that bullet and move on. YMMV Many thanks in advance, Jeremy -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/de4fefa5-6dcf-4419-91f8-a6451cac781en%40googlegroups.com. -- Signed email is an absolute defence against phishing. This email has been signed with my private key. If you import my public key you can automatically decrypt my signature and be sure it came from me. Just ask and I'll send it to you. Your email software can handle signing.
-- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e915618e-274c-4e27-a1d4-8cbc72bcc4a8n%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/62825315.1c69fb81.c11e0.7d45SMTPIN_ADDED_MISSING%40gmr-mx.google.com.