Django version: 3.2
DB: MySQL
My application was built with an old version of Django, so the auto-generated ID field is a 32-bit integer. I’d like to future proof this by moving to 64-bit. I’ve set:
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
in my settings file and created the auto-generated migration files. This seemed to work but when I applied the migrations, it did not handle foreign key relationships correctly. The ID field on the original model was set to a 64-bit integer but the ForeignKey
field in the other was still a 32-bit integer (and a few times, vice versa). The migration then failed and I was unable to rollback without restoring from a backup.
Is anyone aware of any documentation or best practices for ensuring these DB migrations are successful?