blob: b564e4cec1baa1be79f40671eaa30e939e1317ba [file] [log] [blame]
Krzysztof Opasiak17547342020-03-10 23:53:31 +01001--- System Setup
2SET application_name="container_setup";
3
4CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
5CREATE EXTENSION IF NOT EXISTS pgaudit;
6
7ALTER USER postgres PASSWORD '${PG_ROOT_PASSWORD}';
8
9CREATE USER ${PG_PRIMARY_USER} WITH REPLICATION;
10ALTER USER ${PG_PRIMARY_USER} PASSWORD '${PG_PRIMARY_PASSWORD}';
11
12CREATE USER "${PG_USER}" LOGIN;
13ALTER USER "${PG_USER}" PASSWORD '${PG_PASSWORD}';
14
15CREATE DATABASE ${PG_DATABASE};
16GRANT ALL PRIVILEGES ON DATABASE ${PG_DATABASE} TO "${PG_USER}";
17
18CREATE TABLE IF NOT EXISTS primarytable (key varchar(20), value varchar(20));
19GRANT ALL ON primarytable TO ${PG_PRIMARY_USER};
20
21--- PG_DATABASE Setup
22
23\c ${PG_DATABASE}
24
25CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
26CREATE EXTENSION IF NOT EXISTS pgaudit;
27
28--- Verify permissions via PG_USER
29
30\c ${PG_DATABASE} "${PG_USER}";
31
32CREATE SCHEMA IF NOT EXISTS "${PG_USER}";
33
34CREATE TABLE IF NOT EXISTS "${PG_USER}".testtable (
guillaume.lambert30ec3902021-09-14 12:32:24 +020035 name varchar(30) PRIMARY KEY,
36 value varchar(50) NOT NULL,
37 updatedt timestamp NOT NULL
Krzysztof Opasiak17547342020-03-10 23:53:31 +010038);
39
40INSERT INTO "${PG_USER}".testtable (name, value, updatedt) VALUES ('CPU', '256', now());