Created
March 5, 2010 03:41
-
-
Save CNBorn/322430 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
# A bash Script to migrate Sqlite3 DB when Django Model Schema changes. | |
# It will only migrate tables whose Schema unchanged. | |
# cp this script to your Django Project Directory, | |
# then run as sqlitemig.sh yoursqlitedbname.db | |
# Written by CNBorn[%]hotmail.com | |
#echo $1 | |
if test ! -f "$1" | |
then | |
echo "no such file $1" | |
exit 1 | |
fi | |
savedate=$(date +%Y-%m-%d-%H%M%S) | |
#echo $savedate | |
backupdb=$savedate"_"$1 | |
#echo $backupdb | |
tmptxtfile=$savedate"_"txtdump.tmp | |
python manage.py validate | |
sqlite3 $1 .dump > $tmptxtfile | |
cp $1 $backupdb | |
rm $1 | |
python manage.py syncdb | |
sqlite3 $1 ".read $tmptxtfile" | |
rm $tmptxtfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment