Django 1.7 migration to add raw query to set auto_increment initial value

后端 未结 1 1604
醉话见心
醉话见心 2021-01-13 01:03

I am using Django v1.7 and I need to set the initial auto increment value to something like 1000000, I couldn\'t find any Django docs that shows there is a feature like this

相关标签:
1条回答
  • 2021-01-13 01:32

    Sweet, found this documentation

    Just add this in the operations array

    operations = [
        migrations.CreateModel(...),
        # mysql specific
        migrations.RunSQL('alter table tablename auto_increment=1000000'),
    ]
    
    0 讨论(0)
提交回复
热议问题