Skip to content

Commit

Permalink
feat: or-1349 add postgres reset scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
koenmetsu committed Jan 4, 2024
1 parent 771457c commit 5f640db
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .aws/db-recreate.sql → .aws/1.db-recreate.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
drop database if exists verenigingsregister with (force);
create database verenigingsregister;

grant all privileges on database verenigingsregister to verenigingsregister;
grant all privileges on database verenigingsregister to verenigingsregister;
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ GRANT CONNECT ON DATABASE verenigingsregister TO fullaccess;
GRANT USAGE ON SCHEMA public TO fullaccess;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO fullaccess;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO fullaccess;
GRANT INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER ON ALL TABLES IN SCHEMA public TO fullaccess;
GRANT INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER ON ALL TABLES IN SCHEMA public TO fullaccess;
10 changes: 7 additions & 3 deletions .aws/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
FROM public.ecr.aws/aws-cli/aws-cli:2.15.2
FROM postgres:14

LABEL maintainer="Digitaal Vlaanderen <digitaal.vlaanderen@vlaanderen.be>"
LABEL registry="association-registry"

# Install the AWS CLI
RUN apt-get update
RUN apt-get install python3-pip pipx -y

RUN pipx install awscli

COPY .aws/ /app
WORKDIR /app

RUN yum install -y bash curl

ENTRYPOINT ["./init.sh"]
7 changes: 2 additions & 5 deletions .aws/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ wait_for_desired_count() {

# echo "Deletion process completed."

POSTGRES_USERNAME="root"
POSTGRES_PASSWORD="root"

# Reset database
psql -U $POSTGRES_USERNAME -d postgres -f db-recreate.sql -W $POSTGRES_PASSWORD
psql -U $POSTGRES_USERNAME -d verenigingsregister -f db-privilege-grants.sql -W $POSTGRES_PASSWORD
PGPASSFILE=/root/.pgpass psql -h $PG_HOST -d $PG_DB -U $PG_USERNAME -f 1.db-recreate.sql
PGPASSFILE=/root/.pgpass psql -h $PG_HOST -d $PG_DB -U $PG_USERNAME -f 2.db-privilege-grants.sql

0 comments on commit 5f640db

Please sign in to comment.