Saturday, April 25, 2015

Re: Migrations During Development

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJVPCCuAAoJEC0ft5FqUuEhua8QAIzPhzMTejUMMBu0keAqSaJd
OErU3Fc0RudhoJH2OFgeU/BAXBaJsPdlfvPqJksCmKv3WnCUVGOH0yaNZiHbYQZd
q0Wd9X9LKF4SPh9Jfnt1VcItmK4eNjuxNSmVtqDmMZ9eUw5ttRSzE71gGNLDbFSS
wRKht9kMBlMq/BbZk85QmT4+vUvBcmFTRTCkvb2Jxttvy7K+ImOFPUZfic+CKWv2
s1HKD8XA4ExP+r2BPstwCSVxP2Fg83Jmd5gHHJENhERWKkRneSh8zcnTzotIGefc
5JUvAOqJ9f0g4/VFlauHEnm3sseb6vUovrYlv9jGEK/S0j8CEWIZrrCjzHI9QxbS
vAmwUh8svreKtd/twgvAiCCEl6ugHJR2m6/Re5HJXJWYpRwUuMufpoiHGfbNuaGC
eY9mRnk7VWUk2HLslAWuTZo5UY+6m7brfO5pJmypnonnlCGh5Thee/QSyU90UsZY
AXJ72DrTaAfpbu1fQPVNPGXoPwMV461S62wGDjuX8bqyUdYKkzAxfFh1NSG8OL7J
/Q3fDrc/B9Fs2pAT0a5DfX2j3382WW6Y6fJhioWvRwT78MFyyvWvd25sj+ezpQ4+
BF9OFnGBAIfugfu6r0IMNVXMdPcJuoWz6TS4Yq5cS+fNJAA/Ee3NZgF5mc0XgEHl
+D/2sFJ0wCtgi0EUolL/
=M9Sa
-----END PGP SIGNATURE-----
On 04/25/2015 11:28 AM, Timothy W. Cook wrote:
> if you don't store migrations, then you have to generate them on each
> production update, right? if so, wouldn't they count as untested
> code? how about manually tweaked, or data migrations?
>
>
> ​That will certainly be true once you start using a staging or
> production server.
> But before they they are just a kind left over creative ideas. :-) Not
> really useful for anything in the future, AFAICS.

If you only have one deployment (your local machine), you can erase all
your migrations and "start over" anytime with a new initial migration,
with no problems.

Once you have additional deployments (either other developers' machines,
or staging or production deployments), you shouldn't remove or change
any migrations that have been pushed to those other deployments.

You can use the "squash" feature [1] to squash a set of historical
migrations down to a single migration. This requires a phased
deployment, where you first push out a version including both the new
squashed migration and all the old replaced migrations, and then later
(once you are confident all deployments are up to date) you can safely
remove the old replaced migrations.

It's also true that if you have a series of new migrations locally that
haven't yet been pushed to any other deployment, you can delete and
replace them with a single migration before pushing.

It's very much like VCS commits: it's ok to edit your local history, but
you have to be a lot more careful with history that you've already
shared with others.

Carl

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/553C20AE.9080609%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment