Previously, the following invocation would check for pending migrations, output a summary (without writing to disk), and exit with code 1 if any were pending:
$ ./manage.py makemigrations --dry-run --check Migrations for 'example': example/migrations/0002_test.py - Alter field name on author $ echo $? 1
I’ve used this for years, adding it to projects I’ve worked on and recommending it in my book Boost Your Django DX.
Ticket #34051 changed
--check so that it wouldn’t write migrations to disk, whether or not
--dry-run was passed. I like that simplification.
But the change also removed the output listing the pending migrations. That same invocation is now silent from Django 4.2 (whether or not
--dry-run is passed):
$ ./manage.py makemigrations --dry-run --check $ echo $? 1
@shangxiao spotted this regression and opened #34457, and yesterday I clumsily opened a duplicate, #34935. #34457 was wontfixed, with the proposal from @felixxm that projects can now use a double-run approach to check for pending migrations and display them:
RESULT=`./manage.py makemigrations --check` if [ "$RESULT" -gt 0 ]; then ./manage.py makemigrations --dry-run fi; exit $RESULT
I don’t think this is satisfactory. The same invocation no longer shows the pending migrations so I think it should be treated as a regression. Existing projects will need to update if they still want the output. Changing the command to restore the output costs little (see PR) and it can always be silenced with the universal option
Furthermore, it’s inconsistent with
optimizemigration --check, which still outputs what it would do:
$ ./manage.py optimizemigration --check example 0001 Optimizing from 3 operations to 1 operations. $ echo $? 1
Also, it doesn’t seem like the output removal was exactly intentional. It was not part of the proposal that @claudep accepted in the original ticket #34051 , and was not tested before.
On my duplicated ticket #34935, @jacobtylerwalls asked me to seek consensus on this issue. Can I get some feedback on the proposal to restore the output?