Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 336
Zen Reportz Avatar asked Sep 02 '25 16:09

Zen Reportz


1 Answers

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
like image 183
Pavan kumar Avatar answered Sep 05 '25 15:09

Pavan kumar