~mna/hockeypg

37405f4209f73caa361c5bffccbe3ba42b1a3e9b — Martin Angers 1 year, 1 month ago 06f208c master
add src
4 files changed, 17 insertions(+), 3 deletions(-)

M README.md
M db/config/pg/psqlrc
M docker-compose.yml
A src/user.sql
M README.md => README.md +4 -3
@@ 2,9 2,10 @@

## setup

1. Create `.envrc` with required variables
2. Run `./scripts/init.sh`
3. To destroy, run `./scripts/destroy.sh`
1. Run `./scripts/init.sh`
2. Run `./scripts/psql.sh` to get the interactive postgres shell
3. Run `./scripts/sh.sh` to get the interactive bash shell with postgres commands
4. To destroy, run `./scripts/destroy.sh`

The following commands must be installed:


M db/config/pg/psqlrc => db/config/pg/psqlrc +3 -0
@@ 15,3 15,6 @@
\set COMP_KEYWORD_CASE upper
\x auto
\set QUIET 0

-- apply the application's source files
\i /app/src/user.sql

M docker-compose.yml => docker-compose.yml +2 -0
@@ 14,6 14,8 @@ services:
      - ./db/config/pg/pg.conf:/etc/postgresql/postgresql.conf:ro
      - ./db/config/pg/psqlrc:/usr/local/etc/postgresql/psqlrc:ro
      - ./db/config/pg/inputrc:/etc/inputrc:ro

      - ./src:/app/src:ro
      - ./db/data/pg:/var/lib/postgresql/data
    secrets:
      - root_pwd

A src/user.sql => src/user.sql +8 -0
@@ 0,0 1,8 @@
-- create the app user if it doesn't already exist
DO $$
BEGIN
  CREATE USER app;
EXCEPTION WHEN DUPLICATE_OBJECT THEN
  RAISE NOTICE 'user already exists';
END
$$;