Why does django 1.7 creates migrations for changes in field choices?

前端 未结 2 1469
心在旅途
心在旅途 2021-01-03 18:36

I have observed this behaviour on version 1.7 but not in previous versions using south migration.

eg.

class RedemptionCode(models.Model):
    EXPIRE         


        
相关标签:
2条回答
  • 2021-01-03 19:18

    From Django docs:

    Django will make migrations for any change to your models or fields - even options that don’t affect the database - as the only way it can reconstruct a field correctly is to have all the changes in the history, and you might need those options in some data migrations later on (for example, if you’ve set custom validators).

    Reference:

    • https://docs.djangoproject.com/en/dev/topics/migrations/
    0 讨论(0)
  • 2021-01-03 19:32

    After raised the ticket and got closed due to duplication, finally found the answer:

    This is by design. There are several reasons, not least of which for me that datamigrations at points in history need to have a full accurate representation of the models, including all their options not just those which affect the database.

    Reference:

    • https://code.djangoproject.com/ticket/22837
    • https://code.djangoproject.com/ticket/23581
    0 讨论(0)
提交回复
热议问题