I really needed an in-place migration as reloading tens of millions of 
entries was not practical.

I ended up using the migrations I mentioned with one migration per M2M 
intermediate table to avoid locking multiple tables at once.

Cheers,
Jeremy
On Monday, May 16, 2022 at 7:07:19 PM UTC+2 makza...@gmail.com wrote:

> First you need to create table structure in the PostgreSQL, then after 
> import the data into the respective tables.
>
> Makrand Zare
> +919930102832 <+91%2099301%2002832>
> makza...@gmail.com 
>
> On Sun, May 15, 2022, 1:55 PM Mike Dewhirst <mi...@dewhirst.com.au> 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
>>  
>> <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...@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
>>  
>> <https://groups.google.com/d/msgid/django-users/5dd13af9-54e3-e6a0-d8b7-9f736e532d46%40dewhirst.com.au?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/32aa8af2-4a36-46f0-b68c-e6b9d96138b5n%40googlegroups.com.

Reply via email to