Thursday, 4 January 2024

django migrations and rollbacks

 https://stackoverflow.com/questions/32123477/how-to-revert-the-last-migration

make migrations

#requires changes in app model.py

 docker-compose run app sh -c "python manage.py makemigrations <app_name>"

#migration everything

 docker-compose run app sh -c "python manage.py migrate"

# migrate app

 docker-compose run app sh -c "python manage.py migrate <app_name>"


# roll back 

docker-compose run app sh -c "python manage.py showsmigrations <appname>"

then you can select the migration # for the app to roll back to, rolling back to this migration will automatically delete tables index created by other migrations after this 


docker-compose run app sh -c "python manage.py migrate <appName> <number>"



No comments:

Post a Comment