I have a problem with migrations. I'm using database which was created with old Django version 1.4 in new application with Django version >5. The problem is that old Django is using different data type for primary key field (AutoField - int in database). So in database datatype of old django's primary key is "int" and in the new Django datatype is "bigint". I've created new model with Foreign Key to old model and now I'm facing an error:
Column 'tbl1.id' is not the same data type as referencing column 'tbl2.field_id' in foreign key 'tb1_field_id_tbl2_id'
How can I solve this problem?
Only thing that help is to assign db_constraint=True in the models.ForeignKey field. But I don't want have this risk.
Things that I've already tried:
to_field="id"
db_constraint=False
- it helps but not the best solution.bigint
for foreign key tableI fixed it by combining all the tips. Thanks to @iklinac
DEFAULT_AUTO_FIELD = “django.db.models.AutoField”
.default_auto_field = “django.db.models.BigAutoField”
to default_auto_field = “django.db.models.AutoField”
.