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