What is the effect of indexes if I don't run DB migrations?

I have a model with meta:

class Meta:
        db_table = 'table1'
        indexes = [

But I create database manually and don’t use migrations. What is the effect of indexes if I don’t run DB migrations?

The indexes are a database thing.
Django let’s you define the indexes in your model, so when you run the migration, this index gets created on the database. It won’t have any effect if the actual index is not created on the database.

So if you’re manually managing your database, you should set managed = False on your Meta class. And create the index manually on the database. So, defining the indexes on the django model on a not managed model will do nothing for you.

But if you want that django handles your database schema changes (which is recommended), you should then create a migration and run it.

1 Like