Skip to content

Instantly share code, notes, and snippets.

@jamie-ga
Last active August 29, 2015 14:24
Show Gist options
  • Save jamie-ga/64eee76174aff35c5561 to your computer and use it in GitHub Desktop.
Save jamie-ga/64eee76174aff35c5561 to your computer and use it in GitHub Desktop.
Migrations one-line scripts
# Do a load of inline edits using grep instead of perl
for d in $(grep -rl "from conf.cache_times" *); do sed -i '' 's/from conf.cache_times/from sites.conf.cache_times/g' $d; done
# Rename a load of directories from the command line
for d in $(find . -name 'migrations' -type d); do mv $d $(echo $d | sed 's/migrations/south_migrations/' | sed 's/\.\///g'); done
# Running a series of makemigrations on the apps found that do not already have migrations
for d in $(find . -type d -maxdepth 1); do if [ ! -d "$d/migrations" ]; then python manage.py makemigrations $(echo $d | sed 's/\.\///'); fi; done
# using awk - get stuff between double quotes
awk -F '"' '{print $2}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment