annotate db_schema/setup-db.sh @ 924:34c04b0557ac

Added missing UNIQUE-Constraint.
author Tom Gottfried <tom@intevation.de>
date Fri, 15 Apr 2016 10:18:24 +0200
parents 51051e85348f
children 2b746f4e97d6
rev   line source
742
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
1 #!/bin/sh
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
2 DIR=`dirname $0`
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
3
854
e797391714a0 Allow setting variables via commandline.
Tom Gottfried <tom@intevation.de>
parents: 764
diff changeset
4 ROLE_NAME=${1:-lada}
e797391714a0 Allow setting variables via commandline.
Tom Gottfried <tom@intevation.de>
parents: 764
diff changeset
5 ROLE_PW=${2:-$ROLE_NAME}
e797391714a0 Allow setting variables via commandline.
Tom Gottfried <tom@intevation.de>
parents: 764
diff changeset
6 DB_NAME=${3:-$ROLE_NAME}
742
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
7
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8 psql --command "CREATE USER $ROLE_NAME PASSWORD '$ROLE_PW';"
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9 createdb -E UTF-8 $DB_NAME
866
d47e6b8f3897 Reorganise database setup scripts.
Tom Gottfried <tom@intevation.de>
parents: 854
diff changeset
10
d47e6b8f3897 Reorganise database setup scripts.
Tom Gottfried <tom@intevation.de>
parents: 854
diff changeset
11 psql -d $DB_NAME --command \
d47e6b8f3897 Reorganise database setup scripts.
Tom Gottfried <tom@intevation.de>
parents: 854
diff changeset
12 "CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public"
d47e6b8f3897 Reorganise database setup scripts.
Tom Gottfried <tom@intevation.de>
parents: 854
diff changeset
13
d47e6b8f3897 Reorganise database setup scripts.
Tom Gottfried <tom@intevation.de>
parents: 854
diff changeset
14 psql -d $DB_NAME -f $DIR/stammdaten_schema.sql
742
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
15 psql -d $DB_NAME -f $DIR/lada_schema.sql
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
16 psql -d $DB_NAME --command \
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17 "GRANT USAGE ON SCHEMA stammdaten, bund, land TO $ROLE_NAME;
764
9d2070b84238 Hibernate needs nextval to insert new datasets.
Tom Gottfried <tom@intevation.de>
parents: 752
diff changeset
18 GRANT USAGE
752
0cf9387c8da2 Added grant to all sequences.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 742
diff changeset
19 ON ALL SEQUENCES IN SCHEMA stammdaten, bund, land TO $ROLE_NAME;
742
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
20 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES
17165e710631 Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21 ON ALL TABLES IN SCHEMA stammdaten, bund, land TO $ROLE_NAME;"
908
51051e85348f Added data dumps.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 866
diff changeset
22
51051e85348f Added data dumps.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 866
diff changeset
23 psql -d $DB_NAME -f $DIR/stammdaten_data.sql
51051e85348f Added data dumps.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 866
diff changeset
24 psql -d $DB_NAME -f $DIR/lada_data.sql
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)