Django - Will adding or removing an index from a table every create an issue with the database and migrations?

Viewed 551

I want to understand if adding or removing indexes from models creates issues with migrations

Please indicate if any step(s) cause issues with migrations

A) On Day One I create the following model

class Person(models.Model):
    person_name = models.CharField(max_length=50)
    create_date = models.DateTimeField()
    country = models.ForeignKey(Country, on_delete=models.CASCADE)

run migrate and makemigrations commands

B) 20,000 records of data are added for the Person model

C) I add an index to the person_name field

class Person(models.Model):
    person_name = models.CharField(max_length=50, db_index=True)
    create_date = models.DateTimeField()
    country = models.ForeignKey(Country, on_delete=models.CASCADE)

run migrate and makemigrations commands

D) I remove the index from the person_name field

class Person(models.Model):
    person_name = models.CharField(max_length=50)
    create_date = models.DateTimeField()
    country = models.ForeignKey(Country, on_delete=models.CASCADE)

run migrate and makemigrations commands

0 Answers
Related