Detect if you need South Migration?
When working between two branches, often you want to find out if there were migrations. This Unix command tells you if there are any migrations needed and if so, the apps that need the migrations in your Django project.
From your project folder run this:
git diff origin/branch1 origin/branch2 --name-only | grep migrations | cut -d "/" -f 2 | uniq
git diff origin/branch1 origin/branch2 --name-only:
Shows the file names that have changed between the two diffs.
grep migrations
Looks for any files that have migrations in them. (Make sure you dont check in file that have names as migrations.
cut -d "/" -f 2:
Takes the app name from the file name.
uniq:
When you have multiple migrations, lists one for each app folder instead of duplicates.
Written by Amol Kher
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#