[Django] #25604: Add --check flag to makemigrations; return 0 exit status for no new migrations

15 views
Skip to first unread message

Django

unread,
Oct 24, 2015, 10:37:45 AM10/24/15
to django-...@googlegroups.com
#25604: Add --check flag to makemigrations; return 0 exit status for no new
migrations
--------------------------------------------+--------------------
Reporter: jdufresne | Owner: nobody
Type: New feature | Status: new
Component: Core (Management commands) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------------+--------------------
Django developers discussion: https://groups.google.com/forum/#!msg
/django-developers/zczdY6c9KSg/ZXCXQsGDDAAJ

Proposal: add {{{--check}}} flag to the {{{makemigrations}}} management
command. This flag will return 0 if no new migrations will be created. It
will return non-zero if models contain changes without migrations. This
will deprecrate the {{{--exit}}} flag originally discussed here:
https://groups.google.com/forum/#!topic/django-developers/I3M6B-
wYYd8/discussion. The problem with {{{--exit}}} is that it return the
opposite exit status from what continuous integration servers typically
expect.

My use case:

Continuous integration server check's developers' commits for correctness.
One aspect of correctness is that all model changes have migrations.

In shell scripting and CI servers an exit status of 0 indicates true/pass
and an exit status of non-zero indicates false/failure.

Therefore, the command should return 0 when everything is OK and correct
and non-zero otherwise. Commits are correct when all model changes are
accounted for.

The current --exit behavior, returns non-zero when everything is correct.
To account for this in CI, one must negate the exit status with !, this
goes against conventional behavior.

Further, if something goes terribly wrong and there is an unhandled
exception, negating the exit status will make the CI stage appear to pass.
This is backwards! CI can't tell the difference between "all changes
accounted for" and "Python had an unhandled exception".

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

Django

unread,
Oct 24, 2015, 11:03:18 AM10/24/15
to django-...@googlegroups.com
#25604: Add --check flag to makemigrations; return 0 exit status for no new
migrations
-------------------------------------+-------------------------------------

Reporter: jdufresne | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jdufresne):

* needs_better_patch: => 0
* has_patch: 0 => 1
* needs_tests: => 0
* needs_docs: => 0


Comment:

https://github.com/django/django/pull/5453

--
Ticket URL: <https://code.djangoproject.com/ticket/25604#comment:1>

Django

unread,
Oct 24, 2015, 1:38:51 PM10/24/15
to django-...@googlegroups.com
#25604: Add --check flag to makemigrations; return 0 exit status for no new
migrations
-------------------------------------+-------------------------------------

Reporter: jdufresne | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/25604#comment:2>

Django

unread,
Oct 24, 2015, 2:45:20 PM10/24/15
to django-...@googlegroups.com
#25604: Add --check flag to makemigrations; return 0 exit status for no new
migrations
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody
Type: New feature | Status: closed

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"3c7d2ee881b13c7fdd0aa90b0aba0430310786de" 3c7d2ee]:
{{{
#!CommitTicketReference repository=""
revision="3c7d2ee881b13c7fdd0aa90b0aba0430310786de"
Fixed #25604 -- Added makemigrations --check option.

Command exits with non-zero status if changes without migrations exist.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25604#comment:3>

Django

unread,
Jan 17, 2017, 10:09:51 PM1/17/17
to django-...@googlegroups.com
#25604: Add --check flag to makemigrations; return 0 exit status for no new
migrations
-------------------------------------+-------------------------------------
Reporter: Jon Dufresne | Owner: nobody

Type: New feature | Status: closed
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"e0910dcc9283cd8f782cb97836c291f6f395f3f0" e0910dcc]:
{{{
#!CommitTicketReference repository=""
revision="e0910dcc9283cd8f782cb97836c291f6f395f3f0"
Refs #25604 -- Removed makemigrations --exit option per deprecation
timeline.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25604#comment:4>

Django

unread,
Jan 20, 2018, 10:44:38 AM1/20/18
to django-...@googlegroups.com
#25604: Add --check flag to makemigrations; return 0 exit status for no new
migrations
-------------------------------------+-------------------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: New feature | Status: closed
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"b98dc1706e9c63a4cc7d061a3d8a95f6cbf5e950" b98dc170]:
{{{
#!CommitTicketReference repository=""
revision="b98dc1706e9c63a4cc7d061a3d8a95f6cbf5e950"
Refs #25604 -- Removed docs for makemigrations --exit.

Follow up to e0910dcc9283cd8f782cb97836c291f6f395f3f0.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25604#comment:5>

Django

unread,
Jan 20, 2018, 10:45:29 AM1/20/18
to django-...@googlegroups.com
#25604: Add --check flag to makemigrations; return 0 exit status for no new
migrations
-------------------------------------+-------------------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: New feature | Status: closed
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"b749c356189202541e815a78eb09575e25aafd45" b749c356]:
{{{
#!CommitTicketReference repository=""
revision="b749c356189202541e815a78eb09575e25aafd45"
[2.0.x] Refs #25604 -- Removed docs for makemigrations --exit.

Follow up to e0910dcc9283cd8f782cb97836c291f6f395f3f0.
Backport of b98dc1706e9c63a4cc7d061a3d8a95f6cbf5e950 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25604#comment:6>

Reply all
Reply to author
Forward
0 new messages