4

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.

2
  • 1
    Which database are you using? You could just dump the table definitions from your database? Commented Jun 24, 2020 at 4:28
  • I am doing that. but I wanted to see if I can do without sql using django Commented Jun 24, 2020 at 4:46

2 Answers 2

6

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 
Sign up to request clarification or add additional context in comments.

Comments

-1

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

1 Comment

I am trying to Prints the SQL for all migration django. I can use python manage.py sqlmigrate one by one. However, I am trying to see if there is too that does for all migration at same time.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.