Last active
August 29, 2015 14:07
-
-
Save ydm/7a7fb6bc1c76fcbae093 to your computer and use it in GitHub Desktop.
Automates the process of converting south applications to Django 1.7. Use at your own risk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# south2django17 PROJECT_ROOT_WHERE_ALL_THE_APPS_ARE | |
# This script will: | |
# 1. Backup all South migration files to /tmp | |
# 2. Delete these files | |
# 3. Run manage.py makemigrations | |
# 4. Run manage.py migrate | |
# http://is.gd/fbtuPF | |
if [ -z $1 ] | |
then | |
ROOT=$PWD | |
else | |
ROOT=$(readlink -f $1) | |
fi | |
dirs=$(find $ROOT -type d -name migrations) | |
for d in $dirs | |
do | |
app=$(basename $(dirname $d)) | |
dest=/tmp/s2d-$(date -Iseconds)-$app | |
echo Moving $app migrations to $dest | |
echo mkdir $dest | |
echo mv -t $dest $d/* | |
touch $d/__init__.py | |
# convert_app $app | |
done | |
if [ -f $ROOT/manage.py ] | |
then | |
for p in python2.7 python2 python | |
do | |
if which $p 1>/dev/null | |
then | |
$p $ROOT/manage.py makemigrations | |
$p $ROOT/manage.py migrate | |
fi | |
break | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment