Ajout : local/swap : calcule préçisément l'utilisation du swap de chaque processus.
[lhc/ateliers.git] / local / postgresql-schema-create
1 #!/bin/sh -eux
2 db="$1"
3 schema="${2:-$db}"
4 owner="${3:-$schema}"
5 sudo -u postgres psql "$db" -a -f - --set ON_ERROR_STOP=1 <<-EOF
6 DO LANGUAGE plpgsql \$\$
7 BEGIN
8 IF NOT EXISTS (
9 SELECT *
10 FROM pg_catalog.pg_namespace
11 WHERE nspname = '$schema'
12 LIMIT 1
13 ) THEN
14 CREATE SCHEMA $schema
15 AUTHORIZATION $owner;
16 END IF;
17 END;
18 \$\$;
19 EOF