Changing options for STATUS is not triggering new db migrations like desired
See original GitHub issueGiven that behind the scenes we are having syntax sugar for a CharField with some fixed choices, I was expecting the same behavior, which is: any change on the choices tuple causes a new migration.
Having a model like this:
class Article(StatusModel):
STATUS = Choices('draft', 'published')
if I later modify it like this,
class Article(StatusModel):
STATUS = Choices('draft', 'published', 'finished')
manage.py makemigrations reports No changes detected
However, if the new option added is the first one, like here
class Article(StatusModel):
STATUS = Choices('predraft', 'draft', 'published')
manage.py makemigrations creates a new migration
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
Rails: I update migration file then run db ... - Stack Overflow
I've added the field in the migration file (under db\migrate), then ran 'rake db:migrate' which ran without troubles. My text editor even told...
Read more >Managing Migrations - EF Core - Microsoft Learn
You are free to move Migrations files and change their namespace manually. New migrations are created as siblings of the last migration.
Read more >Versioned Migrations | ent - Entgo.io
We emphasize to use the first option, as it has the advantage of not having to connect to a production database to create...
Read more >How to Migrate a Database in PHP Using Phinx
What Are Database Migrations? ... In basic terms, migrations contain changes that you wish to make to your database. These changes could be ......
Read more >Django Migrations: A Primer - Real Python
SQL is also used to create, change, and delete the database tables themselves. Working directly with SQL can be quite cumbersome, so to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @jmansilla !
I guess the answer is related to this part of the documentation:
[...] sets its default value to the first item in the STATUS choices.That explains the different behaviors you encountered. In the first situation, you add a value at the end, which doesn’t impact the default value of the
StatusField.But when you add a new value at the beginning, this changes the default value from your
StatusField, which Django detects to trigger a new migration.If you don’t want this behavior, fixing a default value for your
StatusFieldwould solve your issue, as you will then be insensitive to your choice list ordering.I’m not a great fan of hidden logic like “the first one is the default value” without being really explicit, but the documentation explains it, and changing now this behavior would probably annoy a lot of people that didn’t set any default value for their
StatusField.@nemesisdesign we would need a bit more context to help you, like your models, your migrations, …
+1 I have a bunch of migrations which enumerate the possible statuses, but adding a new status does not seem to affect existing migrations