Mercurial > lada > lada-server
annotate db_schema/setup-db.sh @ 742:17165e710631
Add script to set up database as user postgres.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 26 Oct 2015 15:47:51 +0100 |
parents | |
children | 0cf9387c8da2 |
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 |
17165e710631
Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
4 ROLE_NAME=lada |
17165e710631
Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
5 ROLE_PW=lada |
17165e710631
Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
6 DB_NAME=lada |
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 |
17165e710631
Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
10 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
|
11 psql -d $DB_NAME --command \ |
17165e710631
Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
12 "GRANT USAGE ON SCHEMA stammdaten, bund, land TO $ROLE_NAME; |
17165e710631
Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
13 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES |
17165e710631
Add script to set up database as user postgres.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
14 ON ALL TABLES IN SCHEMA stammdaten, bund, land TO $ROLE_NAME;" |