Do django db_index migrations run concurrently?

With Django 1.10 migrations you can create a concurrent index by using RunSQL and disabling the wrapping transaction by making the migration non-atomic by setting atomic = False as a data attribute on the migration:

class Migration(migrations.Migration):
    atomic = False # disable transaction

    dependencies = []

    operations = [
        migrations.RunSQL('CREATE INDEX CONCURRENTLY ...')
    ]
  • RunSQL: https://docs.djangoproject.com/en/1.10/ref/migration-operations/#runsql
  • Non-atomic Migrations: https://docs.djangoproject.com/en/1.10/howto/writing-migrations/#non-atomic-migrations

There are AddIndexConcurrently and RemoveIndexConcurrently in Django 3.0:

https://docs.djangoproject.com/en/dev/ref/contrib/postgres/operations/#django.contrib.postgres.operations.AddIndexConcurrently

Create a migration and then change migrations.AddIndex to AddIndexConcurrently. Import it from django.contrib.postgres.operations.