Wednesday, August 23, 2017

Re: is there any way to dump all sqlmigrations automatically ?

You can try this command:

 python manage.py showmigrations -p | sed -e 's/\[ ] \(.*\)\.\(.*\)/\1 \2/' |  xargs -L1 python manage.py sqlmigrate

Here is what it does:

1. "python manage.py showmigrations -p" shows all migrations in the order they will be applied as a list with checkboxes.
2. "sed -e 's/\[ ] \(.*\)\.\(.*\)/\1 \2/'" will remove the checkboxes and split the migrations into app and migration name
3. "xargs -L1 python manage.py sqlmigrate" will execute python manage.py sqlmigrate for each line

Alternatively, why not just call python manage.py migrate?

On Wednesday, August 23, 2017 at 3:41:24 AM UTC+2, Victor Wang wrote:
use "sqlmigrate " is too ineffective  to get all sql script to setup new database . 

is there anyway to dump all "sqlmigrate" for all apps ?

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/923bcb7b-982c-4e14-b04f-c3fd492ab06d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment