From 415ebb738da2a9625d6cc1456f4e99e463797c31 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Tue, 3 Dec 2013 12:51:04 +0000 Subject: bitbake: toaster: migrate orm models to South As Toaster advances, database schema alteration will force users to delete old versions and lose all data collected. In order to prevent this, and to allow database updates to happen without having to delete old data, we use South to handle migrations for the ORM application which stores the Toaster data. [YOCTO #5559] (Bitbake rev: 6936faed8d94f3a2ab4055049cd27d02d8229003) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/bin/toaster | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'bitbake/bin') diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index 7e51014b7d..fc59fe5547 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster @@ -40,9 +40,16 @@ function webserverStartAll() { retval=0 python $BBBASEDIR/lib/toaster/manage.py syncdb || retval=1 + python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=2 if [ $retval -eq 1 ]; then echo "Failed db sync, stopping system start" 1>&2 - else + elif [ $retval -eq 2 ]; then + echo -e "\nError on migration, trying to recover... \n" + python $BBBASEDIR/lib/toaster/manage.py migrate orm 0001_initial --fake + retval=0 + python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=1 + fi + if [ $retval -eq 0 ]; then python $BBBASEDIR/lib/toaster/manage.py runserver 0.0.0.0:8000 ${BUILDDIR}/toaster_web.log 2>&1 & echo $! >${BUILDDIR}/.toastermain.pid fi return $retval @@ -92,6 +99,13 @@ if ! echo "import django; print (1,5) == django.VERSION[0:2]" | python 2>/dev/nu return 2 fi +if ! echo "import south; print [0,8,4] == map(int,south.__version__.split(\".\"))" | python 2>/dev/null | grep True >/dev/null; then + echo -e "This program needs South 0.8.4. Please install with\n\nsudo pip install south==0.8.4" + return 2 +fi + + + # Determine the action. If specified by arguments, fine, if not, toggle it -- cgit v1.2.3-54-g00ecf