I have a table in production that is integrated everywhere in the system, now I need to add a new column in the table with a default value, but don't want to change all the existing logic, what is the best way to do that?
class People(models.Model):
name = models.CharField(max_length=20)
gender = models.CharField(max_length=20)
class = models.CharField(max_length=20)
in the system, we have this kind of query everywhere
People.objects.filter(gender='male')
People.objects.filter(gender='female', class="3rd")
...
Now we need to add a new field:
class People(models.Model):
name = models.CharField(max_length=20)
gender = models.CharField(max_length=20)
class = models.CharField(max_length=20)
graduated = models.BooleanField(default=False)
Assume that all the existing data should have graduated is False, so all the existing logic should work if we can add graduated=False on every query, but is there any way we can do so we don't need to change any of the existing code but they will assume graduated=False?