Mercurial > lada > lada-server
comparison db_schema/setup-db.sh @ 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 | 4d8b8c849935 |
children | 2977a7ac414f 299f4ba86090 |
comparison
equal
deleted
inserted
replaced
965:ad69878b7280 | 966:bc44dcda6f69 |
---|---|
1 #!/bin/sh -e | 1 #!/bin/sh -e |
2 # SYNOPSIS | 2 # SYNOPSIS |
3 # ./setup-db.sh [-c] [ROLE_NAME] [ROLE_PW] [DB_NAME] | 3 # ./setup-db.sh [-cn] [ROLE_NAME] [ROLE_PW] [DB_NAME] |
4 # -c clean - drop an existing database | 4 # -c clean - drop an existing database |
5 # -n no data - do not import example data | |
5 # ROLE_NAME name of db user (default = lada) | 6 # ROLE_NAME name of db user (default = lada) |
6 # ROLE_PW login password (default = ROLE_NAME) | 7 # ROLE_PW login password (default = ROLE_NAME) |
7 # DB_NAME name of the databaes (default = ROLE_NAME) | 8 # DB_NAME name of the databaes (default = ROLE_NAME) |
8 # | 9 # |
9 # There will be used a remote database server if there exists the | 10 # There will be used a remote database server if there exists the |
10 # enviroment variable DB_SRV and optional DB_PORT | 11 # enviroment variable DB_SRV and optional DB_PORT |
11 | 12 |
12 DIR=`dirname $0` | 13 DIR=`dirname $0` |
13 | 14 |
14 while getopts "c" opt; do | 15 while getopts "cn" opt; do |
15 case "$opt" in | 16 case "$opt" in |
16 c) | 17 c) |
17 DROP_DB="true" | 18 DROP_DB="true" |
19 ;; | |
20 n) | |
21 NO_DATA="true" | |
18 ;; | 22 ;; |
19 esac | 23 esac |
20 done | 24 done |
21 | 25 |
22 shift $((OPTIND-1)) | 26 shift $((OPTIND-1)) |
65 GRANT USAGE | 69 GRANT USAGE |
66 ON ALL SEQUENCES IN SCHEMA stammdaten, bund, land TO $ROLE_NAME; | 70 ON ALL SEQUENCES IN SCHEMA stammdaten, bund, land TO $ROLE_NAME; |
67 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES | 71 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES |
68 ON ALL TABLES IN SCHEMA stammdaten, bund, land TO $ROLE_NAME;" | 72 ON ALL TABLES IN SCHEMA stammdaten, bund, land TO $ROLE_NAME;" |
69 | 73 |
70 echo import stammdaten | 74 if [ "$NO_DATA" != "true" ]; then |
71 psql $DB_CONNECT_STRING -d $DB_NAME -f $DIR/stammdaten_data.sql | 75 echo import stammdaten |
76 psql $DB_CONNECT_STRING -d $DB_NAME -f $DIR/stammdaten_data.sql | |
72 | 77 |
73 echo import lada test data | 78 echo import lada test data |
74 psql $DB_CONNECT_STRING -d $DB_NAME -f $DIR/lada_data.sql | 79 psql $DB_CONNECT_STRING -d $DB_NAME -f $DIR/lada_data.sql |
80 fi |