#23728: sys.exit(1) from makemigrations if no changes found
-------------------------------------+-------------------------------------
     Reporter:  tim_heap             |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  migrations           |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by mgeisler):

 I found this feature today when I looked for a way to check if someone had
 forgotten to generate and commit all migrations. That is, the error case
 is when there are pending migrations — when `makemigrations --dry-run
 --exit` returns `0`.

 So I need to negate the return value. That is certainly doable, but when
 using Tox, it means depending on an external command (the shell):
 {{{
 [testenv:migrations]
 deps =
     -rrequirements.txt
 commands =
     sh -c '! python manage.py makemigrations --dry-run --exit'
 whitelist_externals =
     sh
 }}}

 My project is Linux-only, so the above should work for me. However, a
 project that wants to support Windows would need a work-around.

 Maybe `makemigrations` could grow a `--check` flag that would enable
 `--dry-run` and exit with `1` if there are pending migrations and `0`
 otherwise?

--
Ticket URL: <https://code.djangoproject.com/ticket/23728#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.f9e11632049a82b7c7318e0593cb9452%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to