Solved: django dump previous migrations

The main problem is that if you dump a migration and then try to run the migrations again, django will not recognize the changes you’ve made and will instead re-run the original migration.


I am trying to dump my previous migrations in Django. I have tried the following command:
<code>python manage.py dumpdata --exclude contenttypes --exclude auth.permission &gt; app/fixtures/initial_data.json</code>
However, this only dumps my current data and not the data from my previous migrations. How can I do this?


A:

You can use <code>--format=json</code> to export your data into a json file and then you can use it as a fixture for your future migrations: 
<code>python manage.py dumpdata --format=json --indent=4 &gt; app/fixtures/initial_data.json  # add all your apps here separated by spaces 
</code>

What is dump

Dump is a command line tool for dumping the contents of a database to a text file.

Wot to make migrations in Django

1.8

There are a few different ways to migrate your data in Django 1.8.

1. Use the migrate command to run a series of migrations on your development server:

$ python manage.py migrate

2. Use the django-migrate tool:

$ pip install django-migrate $ cd myproject $ django-migrate init $ python manage.py migrate

Related posts:

Leave a Comment