Commands that will help you troubleshoot migrations and databases!
So, I made a mess with migrations in the last week, and I learnt a bunch of things, just wanted to share those!
​
**the basic ones:**
Don't run makemigrations on production, run on development and then push and pull
python manage.py makemigrations
python manage.py migrate
​
**for inspection:**
when you make a mess the first thing you should do is understand the current state of your db, I didn't know about these and that cost me a lot. When you understand the state of your db well, you can use --fake to manipulate stuff well.
python manage.py showmigrations
python manage.py dbshell psql
#after the psql command you can use the following to inspect individual tables:
\d {{app}}_{{model | lower}}
python manage.py inspectdb #to understand the schema
​
**for manipulation without deleting/adding stuff in the migrations db:**
***WARNING*** \- Read a lot about this and be extremely careful with what you are doing here, this has potential to massively waste your time and ruin your week if you don't understand what you are doing! (Learn from my mistakes) If you absolutely have to use this,
/r/django
https://redd.it/spa8vo
So, I made a mess with migrations in the last week, and I learnt a bunch of things, just wanted to share those!
​
**the basic ones:**
Don't run makemigrations on production, run on development and then push and pull
python manage.py makemigrations
python manage.py migrate
​
**for inspection:**
when you make a mess the first thing you should do is understand the current state of your db, I didn't know about these and that cost me a lot. When you understand the state of your db well, you can use --fake to manipulate stuff well.
python manage.py showmigrations
python manage.py dbshell psql
#after the psql command you can use the following to inspect individual tables:
\d {{app}}_{{model | lower}}
python manage.py inspectdb #to understand the schema
​
**for manipulation without deleting/adding stuff in the migrations db:**
***WARNING*** \- Read a lot about this and be extremely careful with what you are doing here, this has potential to massively waste your time and ruin your week if you don't understand what you are doing! (Learn from my mistakes) If you absolutely have to use this,
/r/django
https://redd.it/spa8vo
reddit
Commands that will help you troubleshoot migrations and databases!
So, I made a mess with migrations in the last week, and I learnt a bunch of things, just wanted to share those! **the basic...