Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
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