Question about squashing django migrations

158 views
Skip to first unread message

Richard Brockie

unread,
Aug 1, 2015, 6:27:17 PM8/1/15
to Django users
Hi everyone,

Can someone please explain the implications of this note about squashing migrations in the documentation?

From: https://docs.djangoproject.com/en/1.7/topics/migrations/

"Once you’ve squashed a migration, you should not then re-squash that squashed migration until you have fully transitioned it to a normal migration."

 Is there a transition command to convert a squashed migration into a normal migration, or how should I go about this?

Here is my current migration situation:

Migrations:
  • 0001_initial.py
  • ...
  • 0052_auto_20150711_1407.py
have been squashed into:
  • 0001_squashed_0052_auto_20150711_1407.py
Since then, I have created further migrations:
  • 0002_auto_20150731_0651.py
  • 0003_auto_20150731_0659.py
I was a little surprised that the numbering continued from 0002 and not 0053. I am concerned that I will become confused with the overlapping numbering before/after the squash so I would like to streamline things a little. I'm ok to remove the first set of migrations 0001 to 0052 as they are correctly captured by the first squash.

What are your recommendations in a case like this?

Thanks!
Richard Brockie



Carl Meyer

unread,
Aug 10, 2015, 2:12:37 PM8/10/15
to django...@googlegroups.com
Hi Richard,

On 08/01/2015 06:27 PM, Richard Brockie wrote:
> Can someone please explain the implications of this note about squashing
> migrations in the documentation?
>
> From: https://docs.djangoproject.com/en/1.7/topics/migrations/
>
> "Once you’ve squashed a migration, you should not then re-squash
> that squashed migration until you have fully transitioned it to a
> normal migration."
>
>
> Is there a transition command to convert a squashed migration into a
> normal migration, or how should I go about this?

The transition steps are described immediately above the note you
quoted. See the two steps listed right after the text "you must then
transition the squashed migration to a normal initial migration, by:"

> Here is my current migration situation:
>
> Migrations:
>
> * 0001_initial.py
> * ...
> * 0052_auto_20150711_1407.py
>
> have been squashed into:
>
> * 0001_squashed_0052_auto_20150711_1407.py
>
> Since then, I have created further migrations:
>
> * 0002_auto_20150731_0651.py
> * 0003_auto_20150731_0659.py
>
> I was a little surprised that the numbering continued from 0002 and not
> 0053. I am concerned that I will become confused with the overlapping
> numbering before/after the squash so I would like to streamline things a
> little. I'm ok to remove the first set of migrations 0001 to 0052 as
> they are correctly captured by the first squash.
>
> What are your recommendations in a case like this?

To go ahead and remove the old migrations, along with the `replaces`
setting on the new squashed migration, as recommended in the docs. Just
first make sure every deployment of your project has run migrate since
the squash migration was created.

Carl

signature.asc

Richard Brockie

unread,
Aug 10, 2015, 2:16:19 PM8/10/15
to django-users
Hi Carl,

Thanks for pointing this out - it's right there! I don't know how I missed it...

Thanks again,
R.


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/NiKHMhDGMlg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/55C8E971.9050803%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.



--
    R.

Richard Brockie

Real-time bicycle race results - www.ontheday.net
Reply all
Reply to author
Forward
0 new messages