From a9a9f04dbdb8db75498ef9b055bf661e7b4e9d6d Mon Sep 17 00:00:00 2001
From: Andrew Kapuscinski <akapusci@nrao.edu>
Date: Thu, 15 Jul 2021 15:39:13 -0600
Subject: [PATCH] simplified psql commands based on comments from Daniel

---
 Makefile                |  1 -
 ci/psql/init_ngas_db.sh | 11 ++++-------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 5a11f8a28..be68b105a 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,6 @@ cache:
 # Build DB image
 db:
 	docker build --no-cache -t ssa-containers.aoc.nrao.edu/ops/ci/db:workspaces -f ./ci/psql/Dockerfile.db .
-	docker build --no-cache -t ssa-containers.aoc.nrao.edu/ops/ci/db-ngas:workspaces -f ./ci/psql/Dockerfile.db-ngas .
 
 # Build docker images
 build: docker-base db cache
diff --git a/ci/psql/init_ngas_db.sh b/ci/psql/init_ngas_db.sh
index a2fe59688..6157a5b67 100755
--- a/ci/psql/init_ngas_db.sh
+++ b/ci/psql/init_ngas_db.sh
@@ -7,12 +7,9 @@ DB=ngas
 PATH_TO_SQL_FILE=/repos/ngas/src/ngamsCore/ngamsSql/ngamsCreateTables-PostgreSQL.sql
 
 echo "Creating database '$DB' "
+createdb -U $POSTGRES_USER -O $POSTGRES_USER $DB
 
-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
-        CREATE DATABASE $DB;
-        GRANT ALL PRIVILEGES ON DATABASE $DB TO archive;
-EOSQL
+echo "Populating database '$DB' "
+psql -U $POSTGRES_USER -1 -d $DB -f $PATH_TO_SQL_FILE
 
-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname $DB < $PATH_TO_SQL_FILE
-
-echo "'$DB' was created successfully"
+echo "'$DB' was created and populated successfully"
-- 
GitLab