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 migrationsHowever, 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+unsubscr...@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 <https://groups.google.com/d/msgid/django-users/de4fefa5-6dcf-4419-91f8-a6451cac781en%40googlegroups.com?utm_medium=email&utm_source=footer>.
-- 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/5dd13af9-54e3-e6a0-d8b7-9f736e532d46%40dewhirst.com.au.
OpenPGP_signature
Description: OpenPGP digital signature