diff --git a/dmp-db-scema/createDB/createdb.bat b/dmp-db-scema/createDB/createdb.bat new file mode 100644 index 000000000..0214648e5 --- /dev/null +++ b/dmp-db-scema/createDB/createdb.bat @@ -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 \ No newline at end of file diff --git a/dmp-db-scema/createDB/createdb.sh b/dmp-db-scema/createDB/createdb.sh new file mode 100644 index 000000000..fced0c832 --- /dev/null +++ b/dmp-db-scema/createDB/createdb.sh @@ -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 \ No newline at end of file diff --git a/dmp-db-scema/main/createDatabase.sql b/dmp-db-scema/main/createDatabase.sql new file mode 100644 index 000000000..0229c7107 --- /dev/null +++ b/dmp-db-scema/main/createDatabase.sql @@ -0,0 +1,2 @@ +CREATE USER :POSTGRES_USER with PASSWORD :'POSTGRES_PASSWORD' SUPERUSER; +CREATE DATABASE :POSTGRES_DB; \ No newline at end of file diff --git a/dmp-db-scema/updates/08/03_Create_Credentials.sql b/dmp-db-scema/updates/08/03_Create_Credentials.sql index 0ffbf0f46..6ca13e4fc 100644 --- a/dmp-db-scema/updates/08/03_Create_Credentials.sql +++ b/dmp-db-scema/updates/08/03_Create_Credentials.sql @@ -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."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');