Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run django migrations with one command

I have an issue with Django migration. I have more than one database in my project. And I want to do the migration for all of them. I wrote my own migrations and if I run the commands below, everything works fine.

python manage.py migrate app-name first_migration
python manage.py migrate --datatbase=db_1 app-name first_migration
python manage.py migrate --datatbase=db_2 app-name first_migration

python manage.py migrate app-name second_migration
python manage.py migrate --datatbase=db_1 app-name second_migration
python manage.py migrate --datatbase=db_2 app-name second_migration

python manage.py migrate app-name third_migration
python manage.py migrate --datatbase=db_1 app-name third_migration
python manage.py migrate --datatbase=db_2 app-name third_migration

But I want to automate it, to run only:

python manage.py migrate 

Unfortunately, when I do it I have the below error for migration3

django.db.utils.operationalerror no such column: column_name

But column_name was added in migration2

Have anybody any idea, how can I resolve this issue and run all migration with one command?

like image 875
Karol Oleksy Avatar asked Oct 16 '25 20:10

Karol Oleksy


1 Answers

In order to migrate all the models, there are 2 commands:

  1. python manage.py makemigrations
  2. python manage.py migrate
like image 177
Saqib Arsalan Ijaz Avatar answered Oct 18 '25 14:10

Saqib Arsalan Ijaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!