Hello,

Michal is right, except…

If you have only one server running your code, there is no real need to
keep your unsquashed migrations; do a squash, and remove everything else.

If, however, your app's source is public, imagine the following scenario:

You publish your app with 3 migration files. I install it and migrate. Then
you create 2 more, but later decide to squash all 5 into one (resulting in
a 0001_0005 migration file) and remove the old ones. Now I hear about the
cool new feature you just built in and want to use it. I upgrade the app,
run migrate… and Django will miss the 0004 and 0005 files.

If I create an empty migration with the same name of your 0004 (I can check
it in the squashed migration file), then run makemigration, I'll get the
same result as you (I have to rename 0005 again, of course). However, if
you had a RunPython step in your 0004, I will know nothing about it, and
may destroy my data (of course not, I have backups).

=====

I have some Django projects in production, and we always keep migration
files. We also have most of them squashed just in case (it speeds up
testing a lot).

I hope I helped :)

Best,
Gergely

On May 13, 2016 07:42, "Michal Petrucha" <michal.petru...@koniiiik.org>
wrote:
>
> On Thu, May 12, 2016 at 08:11:42PM -0700, Noumia Ngangoum wrote:
> > Yeah Eugene, I know that, that's how I do now.
> > I was looking for a one-liner command or something.
>
> There is no one-liner, because you are not supposed to remove all
> migrations. The entire point of migrations is that once you crate
> them, you keep them together with your code.
>
> Occasionally you might want to squash your migrations, in case the
> migration history becomes too long and takes too much time to process
> one-by-one, but even when you do that, you do not simply remove all
> migrations and reset the migrations table.
>
> Cheers,
>
> Michal
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/20160513054234.GC435%40koniiiik.org
.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBULN2j8evGURO2NPZJaF5%2BjFJbjKuO7tHUU%2B7-Ro3bkrnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to