Skip to content

Commit

Permalink
nipapd: Updated SQL makefile for CI
Browse files Browse the repository at this point in the history
Made some changes to the SQL Makefile to make it suitable to use for
setting up PostgreSQL for testing from Docker.
  • Loading branch information
garberg committed Jun 14, 2024
1 parent d3c32ee commit 8d2ce91
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nipap/sql/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#.PHONY: install
#.PHONY: install auth db tables clean clean-db clean-tables
# vim: ts=8 :

PSQL=psql
Expand Down Expand Up @@ -30,23 +30,23 @@ endif
all:
@echo "Please run \"make install\" as postgres user."


db:
auth:
createuser -S -D -R $(DB_USER)
createdb -O $(DB_USER) $(DB_NAME)
-psql -q -c "ALTER USER $(DB_USER) ENCRYPTED PASSWORD '$(DB_PASS)'"

db:
-psql -d $(DB_NAME) -c "CREATE EXTENSION ip4r;"
-psql -d $(DB_NAME) -c "CREATE EXTENSION hstore;"
-psql -d $(DB_NAME) -c "CREATE EXTENSION citext;"


tables:
PGPASSWORD=$(DB_PASS) cat ip_net.plsql | sed -e 's/%s/$(DB_NAME)/' | psql -q -h localhost -U $(DB_USER) -d $(DB_NAME)
PGPASSWORD=$(DB_PASS) psql -q -h localhost -U $(DB_USER) -d $(DB_NAME) < functions.plsql
PGPASSWORD=$(DB_PASS) psql -q -h localhost -U $(DB_USER) -d $(DB_NAME) < triggers.plsql


install: db tables
install: auth db tables
@echo "##"
ifdef PG_PASS_RAND
@echo "## A random password was generated '$(DB_PASS)'"
Expand Down

0 comments on commit 8d2ce91

Please sign in to comment.