changeset 966:bc44dcda6f69

Add option to create database with schema only.
author Tom Gottfried <tom@intevation.de>
date Thu, 02 Jun 2016 11:43:16 +0200
parents ad69878b7280
children 60c6c5910ea9 69b954343acc
files db_schema/setup-db.sh
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/db_schema/setup-db.sh	Wed Jun 01 15:25:08 2016 +0200
+++ b/db_schema/setup-db.sh	Thu Jun 02 11:43:16 2016 +0200
@@ -1,7 +1,8 @@
 #!/bin/sh -e
 # SYNOPSIS
-# ./setup-db.sh [-c] [ROLE_NAME] [ROLE_PW] [DB_NAME]
+# ./setup-db.sh [-cn] [ROLE_NAME] [ROLE_PW] [DB_NAME]
 #   -c         clean - drop an existing database
+#   -n         no data - do not import example data
 #   ROLE_NAME  name of db user (default = lada)
 #   ROLE_PW    login password  (default = ROLE_NAME)
 #   DB_NAME    name of the databaes (default = ROLE_NAME)
@@ -11,11 +12,14 @@
 
 DIR=`dirname $0`
 
-while getopts "c" opt; do
+while getopts "cn" opt; do
     case "$opt" in
         c)
             DROP_DB="true"
             ;;
+        n)
+            NO_DATA="true"
+            ;;
     esac
 done
 
@@ -67,8 +71,10 @@
       GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES
             ON ALL TABLES IN SCHEMA stammdaten, bund, land TO $ROLE_NAME;"
 
-echo import stammdaten
-psql $DB_CONNECT_STRING -d $DB_NAME -f $DIR/stammdaten_data.sql
+if [ "$NO_DATA" != "true" ]; then
+    echo import stammdaten
+    psql $DB_CONNECT_STRING -d $DB_NAME -f $DIR/stammdaten_data.sql
 
-echo import lada test data
-psql $DB_CONNECT_STRING -d $DB_NAME -f $DIR/lada_data.sql
+    echo import lada test data
+    psql $DB_CONNECT_STRING -d $DB_NAME -f $DIR/lada_data.sql
+fi
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)