Sabine,
I'm not sure about the new 1.7 Migrations, but with South,
restarting your migrations is easy.
I'm currently doing it on my project, because we have a
long convoluted history of changes before and after we
started using South, and have made some mistakes along
the way (like editing migrations and fixtures that they use
after running them -- bad idea!). Since we're at a nice
stable point now, and are certain we'll never need to
migrate back to an earlier version, I'm currently deleting
all the old migrations and creating new clean ones that get
us to our current state.
Steps:
- Delete all rows from south_migrationhistory table.
- For each app
- Delete old migration files from migrations folders
- Run: python manage.py convert_to_south /appname/
to create and fake the 0001_initial.py migration.
This creates a file in the migrations folder and adds
row to the south_migrationhistory claiming that the
migration has already been run.
- For each app with models mapped to DB tables that
contain data you would want to pre-load into a newly
created DB (lookup values like countries, states,
statuses, etc.):
- Run: python manage.py datamigration /appname/ /migration_name/
to create a new migration named 0002_/migration_name/.py
with empty forwards() and backwards() methods.
- For each such DB table:
- Run: python manage.py dumpdata --indent=4 /appname.ModelName/ >
.//appname//fixtures//table_name/.default.json
- Add to forwards() method:
call_command("loaddata", "/table_name/")
--Fred
------------------------------------------------------------------------
Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
------------------------------------------------------------------------
On 9/25/14 1:11 AM, Sabine Maennel wrote:
Dear Andrew,
I read your article and it is great. I am really looking forward to
your followups. I was hoping for something like this went I attended
Django Con Europe. I struggle with the understanding the migrations
the most. Usually in the early phases of development I do not want
migrations to bother me since my database design just still changes
too often for keeping track. I find the django admin a very useful
tool to test your database design with real data and detect flaws
early on. So will your followups contain advise on that? How can I
restart migrations all over once my project is ready for deployment?
Thanks so much for writing these very useful articles! Do you mind if
I post about them in the Django user facebook user group, or do you
want to do that, since I think these articles will be very helpful to
most Django developers.
with kind regards and keep going!
Sabine
Am Donnerstag, 25. September 2014 04:09:20 UTC+2 schrieb Andrew Pinkham:
Hi,
I am writing a series of articles based on the presentation I gave
at DjangoCon US 2014. I put the first article online earlier
today, and figured members of this list might be interested in the
material.
For all of the material:
afrg.co/updj17/ <http://afrg.co/updj17/>
For the article:
afrg.co/updj17/a1/ <http://afrg.co/updj17/a1/>
I plan to post the next three in the series on each of the coming
Wednesdays.
Any feedback appreciated. I hope you find the material helpful.
Andrew
--
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
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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/934a13d6-d5fd-4684-9bb1-e6d323778cda%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/934a13d6-d5fd-4684-9bb1-e6d323778cda%40googlegroups.com?utm_medium=email&utm_source=footer>.
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/542453B6.2070305%40bristle.com.
For more options, visit https://groups.google.com/d/optout.