[Lada-commits] [PATCH] Add option to create database with schema only

Wald Commits scm-commit at wald.intevation.org
Thu Jun 2 11:43:39 CEST 2016


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1464860596 -7200
# Node ID bc44dcda6f699fd5a24af53fea39b05bd1d1225f
# Parent  ad69878b7280499e9ffd378af43d16d83d6222a4
Add option to create database with schema only.

diff -r ad69878b7280 -r bc44dcda6f69 db_schema/setup-db.sh
--- 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


More information about the Lada-commits mailing list