From 1721269db0b3f8c06127379687ffd151e65ede8f Mon Sep 17 00:00:00 2001
From: David Trattnig <david.trattnig@o94.at>
Date: Thu, 30 Apr 2020 11:56:40 +0200
Subject: [PATCH] Added recreate-database.

---
 run.sh | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/run.sh b/run.sh
index f73621e..e9212a5 100755
--- a/run.sh
+++ b/run.sh
@@ -12,13 +12,15 @@ docker="false"
 # - lqs
 # - api-dev
 # - api
-#
+# - recreate-database
+
 # - docker:engine
 # - docker:core
 # - docker:lqs
+# - docker:recreate-database
 # - docker:build
 # - docker:api
-#
+# 
 
 if [[ $* =~ ^(engine|core|lqs|api-dev|api)$ ]]; then 
 	mode=$1 
@@ -78,6 +80,12 @@ if [[ $docker == "false" ]]; then
 		gunicorn -c configuration/gunicorn.conf.py engine-api:app
 	fi
 
+	### CAUTION: This deletes everything in your database ###
+
+	if [[ $mode == "recreate-database" ]]; then
+		/usr/bin/env python3.7 engine-core.py --recreate-database
+	fi
+
 fi
 
 
@@ -137,6 +145,16 @@ if [[ $docker == "true" ]]; then
 			-c "gunicorn -c configuration/gunicorn.conf.py engine-api:app"
 	fi
 
+	### CAUTION: This deletes everything in your database ###
+
+	if [[ $mode == "recreate-database" ]]; then
+		exec sudo docker run --rm -it \
+			-u $UID:$GID \
+			-v "$BASE_D":/srv \
+			-v "$BASE_D/configuration/":/etc/aura \
+			--tmpfs /var/log/aura/ autoradio/engine /srv/engine-core.py --recreate-database
+	fi
+
 	### Create Docker Image from local project ###
 
 	if [[ $mode == "build" ]]; then
-- 
GitLab