Reputation: 17077
My web stack is django/python + postgresql + linux + apache. I use fabric to automate the deployment from local to the server. For the deployment automation, I wish I could include data migration from my local database to the corresponding database on the server. Is there a way to do that? I prefer to see the data migration becoming a fabric task, if possible.
Upvotes: 1
Views: 550
Reputation: 3218
I think you need to somehow export the data to a file / files, copy to the target server, and import them. The utilities to do this in Django (documentation) are dumpdata
and loaddata
.
So on the local database:
django-admin.py dumpdata > mydata.json
Then to the server:
fabric.api.put('mydata.json','/server/data/dir/')
fabric.api.run('django-admin.py loaddata mydata.json')
You should also have a look at South, which is a database migration tool for Django.
Upvotes: 1