Add self deploy scripts for the database (without docker)

This commit is contained in:
George Kalampokis 2020-05-11 18:34:42 +03:00
parent 1335ca5724
commit e2b15f1b82
4 changed files with 16 additions and 1 deletions

View File

@ -0,0 +1,8 @@
@echo off
setlocal
cd ..
for /F "tokens=*" %%p in ('type Docker\dmp-db.env') do SET %%p
psql -d postgres -U postgres -w --set=POSTGRES_USER=%POSTGRES_USER% --set=POSTGRES_PASSWORD=%POSTGRES_PASSWORD% --set=POSTGRES_DB=%POSTGRES_DB% -f main/createDatabase.sql
psql -d dmptool -U dmptool -w -f main/DataManagementPlanDB.sql
for /R "updates" %%f in (*.sql) do psql --set=ADMIN_USERNAME=%ADMIN_USERNAME% --set=ADMIN_PASSWORD=%ADMIN_PASSWORD% -d dmptool -U dmptool -w -f %%f
endlocal

View File

@ -0,0 +1,5 @@
cd ..
source Docker/dmp-db.env
export $(cut -d= -f1 Docker/dmp-db.env)
psql -d postgres -U postgres -w --set=POSTGRES_USER="$POSTGRES_USER" --set=POSTGRES_PASSWORD="$POSTGRES_PASSWORD" --set=POSTGRES_DB="$POSTGRES_DB" -f main/createDatabase.sql
./initdb.sh

View File

@ -0,0 +1,2 @@
CREATE USER :POSTGRES_USER with PASSWORD :'POSTGRES_PASSWORD' SUPERUSER;
CREATE DATABASE :POSTGRES_DB;

View File

@ -21,5 +21,5 @@ ALTER TABLE ONLY public."Credential"
INSERT INTO public."UserInfo"(email, authorization_level, usertype, name, created, additionalinfo) VALUES ('fake@email.org', 1, 1, :'ADMIN_USERNAME', now(), '{}'); INSERT INTO public."UserInfo"(email, authorization_level, usertype, name, created, additionalinfo) VALUES ('fake@email.org', 1, 1, :'ADMIN_USERNAME', now(), '{}');
INSERT INTO public."Credential" VALUES (uuid_generate_v4(), 0, 5, :'ADMIN_USERNAME', :'ADMIN_PASSWORD', now(), now(), (SELECT public."UserInfo"."id" FROM public."UserInfo" WHERE name = 'admin'), 'dmp'); INSERT INTO public."Credential" VALUES (uuid_generate_v4(), 0, 5, :'ADMIN_USERNAME', :'ADMIN_PASSWORD', now(), now(), (SELECT public."UserInfo"."id" FROM public."UserInfo" WHERE name = :'ADMIN_USERNAME'), 'dmp');