Mercurial > dive4elements > river
annotate backend/doc/schema/postgresql-setup.sh @ 5890:6ea004d51203
Datacage: Introduced <dc:group epxr="xpath" type="type"> ... </dc:group> and XPath function dc:group-key().
This splits the current result set into groups formed by expr. The type defaults to string.
Afterwards all these groups are iterated by there natural order.
The dc:group-key() gives access to the result of the grouping expression that forms a group.
Say, you have a result set like this:
name | description
-----+------------
a | foo
a | bar
b | baz
b | bla
c | blub
you can use:
<dc:group expr="$name">
<group name="{dc:group-key()}">
<dc:for-each>
<description value="{$description}"/>
</dc:for-each>
</group>
</dc:group>
to create:
<group name="a">
<description name="foo"/>
<description name="bar"/>
</group>
<group name="b">
<description name="baz"/>
<description name="bla"/>
</group>
<group name="c">
<description name="blub"/>
</group>
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 02 May 2013 20:52:18 +0200 |
parents | 5aa05a7a34b7 |
children | 4ad2b530dbba |
rev | line source |
---|---|
5284
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
1 #!/bin/bash |
5287
a7e8e9bbe6f5
postgresql-setup.sh: Doc improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5284
diff
changeset
|
2 |
a7e8e9bbe6f5
postgresql-setup.sh: Doc improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5284
diff
changeset
|
3 # $1: user name and password for new DB (equals DB name) |
5284
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
4 # $2: path to directory with schema-scripts |
5288
b0f14ff573d7
postgresql-setup.sh: Introduced third (host) parameter, fixed alter user statement
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5287
diff
changeset
|
5 # $3: host |
5284
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
6 |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
7 # run as user postgres (postgresql super-user) |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
8 # it is assumed that the owner of the DB has the same name as the DB! |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
9 |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
10 # create PostGIS-DB |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
11 createuser -S -D -R $1 |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
12 createdb $1 |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
13 createlang plpgsql $1 |
5288
b0f14ff573d7
postgresql-setup.sh: Introduced third (host) parameter, fixed alter user statement
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5287
diff
changeset
|
14 # Appears e.g. as /usr/share/postgresql/contrib/postgis-1.5/ on other systems. |
b0f14ff573d7
postgresql-setup.sh: Introduced third (host) parameter, fixed alter user statement
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5287
diff
changeset
|
15 psql -d $1 -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql |
b0f14ff573d7
postgresql-setup.sh: Introduced third (host) parameter, fixed alter user statement
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5287
diff
changeset
|
16 psql -d $1 -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql |
b0f14ff573d7
postgresql-setup.sh: Introduced third (host) parameter, fixed alter user statement
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5287
diff
changeset
|
17 psql -d $1 -c "ALTER USER $1 WITH PASSWORD '$1';" |
5284
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
18 psql -d $1 -c "GRANT ALL ON geometry_columns TO $1; GRANT ALL ON geography_columns TO $1; GRANT ALL ON spatial_ref_sys TO $1;" |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
19 |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
20 # add credentials to .pgpass (or create .pgpass) |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
21 echo "*:*:$1:$1:$1" >> ~/.pgpass |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
22 chmod 0600 ~/.pgpass |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
23 |
4e79267c3af8
added script to setup postgres-DB for testing
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
24 # apply schema-scripts |
5288
b0f14ff573d7
postgresql-setup.sh: Introduced third (host) parameter, fixed alter user statement
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5287
diff
changeset
|
25 psql -d $1 -U $1 -h $3 -f $2/postgresql.sql |
b0f14ff573d7
postgresql-setup.sh: Introduced third (host) parameter, fixed alter user statement
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5287
diff
changeset
|
26 psql -d $1 -U $1 -h $3 -f $2/postgresql-spatial.sql |
b0f14ff573d7
postgresql-setup.sh: Introduced third (host) parameter, fixed alter user statement
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5287
diff
changeset
|
27 psql -d $1 -U $1 -h $3 -f $2/postgresql-minfo.sql |