add --noobserver option to manage.py
[plstackapi.git] / planetstack / scripts / opencloud
old mode 100755 (executable)
new mode 100644 (file)
index 041f3f8..54852b9
@@ -7,6 +7,8 @@ fi
 
 BACKUP_DIR=/opt/planetstack_backups
 
+DJANGO_17=`python -c "import django; from distutils.version import StrictVersion; print int(StrictVersion(django.get_version()) >= StrictVersion('1.7'))"`
+
 cd /opt/planetstack
 
 function ensure_postgres_running {
@@ -44,11 +46,19 @@ function dropdb {
 function syncdb {
     echo "Syncing OpenCloud services..."
     python /opt/planetstack/manage.py syncdb --noinput
+    if [[ $DJANGO_17 ]]; then
+        echo "Loading initial data from fixture..."
+        python /opt/planetstack/manage.py --noobserver --nomodelpolicy loaddata /opt/planetstack/core/fixtures/initial_data.json
+    fi
 }
 function evolvedb {
-    echo "Syncing OpenCloud services..."
+    echo "Evolving OpenCloud services..."
     python /opt/planetstack/manage.py evolve --hint --execute --noinput
 }
+function migratedb {
+    echo "Migrating OpenCloud services..."
+    python /opt/planetstack/manage.py migrate
+}
 function stopserver {
     echo "Stopping any running OpenCloud Service(s)"
     pkill -f "python.*runserver"
@@ -124,10 +134,14 @@ if [ "$COMMAND" = "restoredb" ]; then
     createdb
     syncdb
 fi
-if [ "$COMMAND" = "evolvedb" ]; then
+if [ "$COMMAND" = "evolvedb" -o "$COMMAND" = "migratedb" ]; then
     stopserver
     ensure_postgres_running
-    evolvedb
+    if [[ $DJANGO_17 ]]; then
+        migratedb
+    else
+        evolvedb
+    fi
 fi
 if [ "$COMMAND" = "resetdb" ]; then
     stopserver