Zen Reportz
Zen Reportz

Reputation: 53

Prints the SQL for all migration django

I have django application, where I wanted to export all migration from my project , auth and admin to sql query. I am able to do

python manage.py sqlmigrate myapp 0001

However, I want to export all migration at same time rather than explicitly righting loops. Is there any package or tool that i can use for this.

Upvotes: 4

Views: 4346

Answers (2)

Pavan kumar
Pavan kumar

Reputation: 515

you can use squashmigrations command

python manage.py squashmigrations <appname> <squashfrom> <squashto>

and press y

Delete all the before migration files

then run the following command

python manage.py sqlmigrate <appname> <squash_generated_migartion_file>

if you wanted to see the sql for auth migrations

python manage.py sqlmigrate auth 0001_initial

Upvotes: 6

Nischal Shrestha
Nischal Shrestha

Reputation: 119

First make sure you are on directory with manage.py file i.e. project directory then, you can do

python manage.py makemigrations

and then run python manage.py migrate or python manage.py sqlmigrate

Upvotes: -1

Related Questions