[Answered ]-Django migrate foreignkey with int index set to 10 digits not 11

2👍

You have one possible option to create forigenKey with int(10). by editing empty migration file.

First create empty migration file with

python manage.py makemigrations --empty myapp

Then edit operations = [] to excute rawsql with forigenKey int(10)
your new migrations file:

class Migration(migrations.Migration):

    dependencies = [
        ('myapp', '0009_auto_20160623_xxxxx'),
    ]

    operations = [
        migrations.RunSQL("ALTER TABLE myapp_table MODIFY field_id int(10);")
    ]

RunSQL requires sqlparse

Leave a comment