Add an --unapplied option for showmigrations

72 views
Skip to first unread message

Sky Christensen

unread,
Nov 29, 2019, 5:59:37 AM11/29/19
to django-d...@googlegroups.com
I'd like to be able to easily see a list of only unapplied migrations.

I often find myself switching to a new branch and wanting to quickly
find out whether it contains any migrations that are yet to be applied
to my development database, and what they are.

At the moment I use a plain `./manage.py showmigrations`, but when there
are lots of migrations, scanning the resulting list to find out which --
if any -- migrations are not yet applied is tedious and error-prone.

I'd really like to be able to do something like `./manage.py
showmigrations --unapplied` or `./manage.py showmigrations -u`, and have
that produce a list of only the unapplied migrations.

I'll be happy to open a ticket and submit a patch to do this if others
think the idea has merit.

Adam Johnson

unread,
Nov 29, 2019, 7:31:38 AM11/29/19
to django-d...@googlegroups.com
I think you want "manage.py migrate --plan" - new in Django 2.2 https://docs.djangoproject.com/en/2.2/ref/django-admin/#cmdoption-migrate-plan

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/8ebd8bdddf81b8fe8fe83f8ee2c8faa2%40skychristensen.com.


--
Adam

Sky Christensen

unread,
Dec 14, 2019, 6:09:35 PM12/14/19
to django-d...@googlegroups.com
Thanks Adam - I hadn't come across that, and think it's what I'm after.

Would it be worth adding a note about this to the "showmigrations"
section of the docs? It strikes me that that's the place people would
look for an answer to the question "How can I see a list of just the
unapplied migrations?".

It could be quite a short note. Something like "To show only the
unapplied migrations, use `django-admin migrate --plan`."
> https://groups.google.com/d/msgid/django-developers/CAMyDDM2Nb_AWfsx05EVydo4PV20iWbcA4GBbZCT_Rn%3De%3D%3DMFXA%40mail.gmail.com
> [1].
>
>
> Links:
> ------
> [1]
> https://groups.google.com/d/msgid/django-developers/CAMyDDM2Nb_AWfsx05EVydo4PV20iWbcA4GBbZCT_Rn%3De%3D%3DMFXA%40mail.gmail.com?utm_medium=email&utm_source=footer

Adam Johnson

unread,
Dec 14, 2019, 6:47:50 PM12/14/19
to django-d...@googlegroups.com
Sure, feel free to open a PR and mention me in a comment with "@adamchainz" so I see it.



--
Adam
Reply all
Reply to author
Forward
0 new messages