-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #839 from bcgov/ricander
Master script for test to deploy empty DB, schema, and data seeding
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- Check if DB exists and drop if it does | ||
DO | ||
$$ | ||
DECLARE | ||
db_name TEXT := 'strdssdev'; | ||
BEGIN | ||
-- Check if the database exists | ||
IF EXISTS ( | ||
SELECT 1 FROM pg_database | ||
WHERE datname = db_name | ||
) THEN | ||
-- Terminate active connections to the database | ||
PERFORM pg_terminate_backend(pid) | ||
FROM pg_stat_activity | ||
WHERE datname = db_name; | ||
END IF; | ||
END; | ||
$$; | ||
|
||
DROP DATABASE IF EXISTS strdssdev; | ||
|
||
-- Check if strdss role exists and drop if it does | ||
DO | ||
$$ | ||
BEGIN | ||
IF EXISTS ( | ||
SELECT 1 FROM pg_roles | ||
WHERE rolname = 'strdssdev' | ||
) THEN | ||
EXECUTE format('DROP ROLE %I', 'strdssdev'); | ||
END IF; | ||
END | ||
$$; | ||
|
||
CREATE ROLE strdssdev WITH LOGIN PASSWORD 'postgres'; | ||
CREATE DATABASE strdssdev; | ||
ALTER DATABASE strdssdev OWNER TO strdssdev; | ||
\c strdssdev | ||
CREATE EXTENSION postgis; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
rem This script must be run from the House-Policy-STRDSS/database/utility folder | ||
rem by replacing 'rem' with '#', this file will run with /bin/sh under Linux | ||
docker cp ../database/utility house-policy-strdss-strdss-db-1:/utility | ||
docker cp ../database/ddl house-policy-strdss-strdss-db-1:/ddl | ||
docker cp ../database/seeding house-policy-strdss-strdss-db-1:/seeding | ||
docker exec -i house-policy-strdss-strdss-db-1 psql -U postgres -f utility/STR_DSS_Database_Create.sql | ||
rem The SQL script below must be the correct sprint migration script for the current sprint (i.e. STR_DSS_Migration_Sprint_<SprintNumber>.sql) | ||
docker exec -i house-policy-strdss-strdss-db-1 psql -U postgres -d strdssdev -f utility/STR_DSS_Migration_Sprint_18.sql |