Skip to content

Commit

Permalink
Merge pull request #88 from bcgov/feature/PIM-1766-Rename-Databases-S…
Browse files Browse the repository at this point in the history
…chemas-in-OpenShift

Feature/pim 1766 rename databases schemas in open shift
  • Loading branch information
mhostett authored Oct 29, 2024
2 parents ed8f0fb + b90e091 commit d8277af
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cirras-underwriting-liquibase/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{ "include": {"file": "scripts/03_00_xx/03_01_01/00/cirras.cuws.03_01_01_00.drop.ddl.json"} },
{ "include": {"file": "scripts/03_00_xx/03_02_00/00/cirras.cuws.03_02_00_00.ddl.json"} },
{ "include": {"file": "scripts/03_00_xx/03_03_00/00/cirras.cuws.03_03_00_00.ddl.json"} },
{ "include": {"file": "scripts/03_00_xx/03_05_00/00/cirras.cuws.03_05_00_00.ddl.json"} },
{ "include": {"file": "scripts/03_00_xx/03_05_00/00/cirras.cuws.03_05_00_00.dml.json"} }
{ "include": {"file": "scripts/03_00_xx/03_05_00/01/cirras.cuws.03_05_00_01.ddl.json"} },
{ "include": {"file": "scripts/03_00_xx/03_05_00/01/cirras.cuws.03_05_00_01.dml.json"} }
]
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
-- Database: cirras${ENV}
-- Database: pituw${ENV}

-- DROP DATABASE "cirras${ENV}";
-- DROP DATABASE "pituw${ENV}";

CREATE DATABASE "cirras${ENV}"
CREATE DATABASE "pituw${ENV}"
WITH
OWNER = postgres
TABLESPACE = pg_default
CONNECTION LIMIT = -1;

COMMENT ON DATABASE "cirras${ENV}"
IS 'cirras${ENV} database containing schemas used by cirras applications and services.';
COMMENT ON DATABASE "pituw${ENV}"
IS 'pituw${ENV} database containing schemas used by production insurance applications and services.';

GRANT TEMPORARY, CONNECT ON DATABASE "cirras${ENV}" TO PUBLIC;
GRANT TEMPORARY, CONNECT ON DATABASE "pituw${ENV}" TO PUBLIC;

GRANT ALL ON DATABASE "cirras${ENV}" TO postgres;
GRANT ALL ON DATABASE "pituw${ENV}" TO postgres;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--The database needs to be renamed.

DEV: pituwdev
QA: pituwqa
DLVR: pituwdlvr
TEST: pituwtest
PROD: pituwprod

--Before running the rename statement, shutdown these apis:
- UW API
- Jasper API

--Rename sql has to be run: ALTER DATABASE old_database_name RENAME TO new_database_name;

DEV: ALTER DATABASE cirrasdev RENAME TO pituwdev;
QA: ALTER DATABASE cirrasqa RENAME TO pituwqa;
DLVR: ALTER DATABASE cirrasdlvr RENAME TO pituwdlvr;
TEST: ALTER DATABASE cirrastest RENAME TO pituwtest;
PROD: ALTER DATABASE cirrasprod RENAME TO pituwprod;


Possible Error if there are sessions using the database:
There are X other sessions using the database.database "cirras_dev" is being accessed by other users
ERROR: database "cirrasdev" is being accessed by other users
SQL state: 55006

Solution: SELECT pg_terminate_backend( pid ) FROM pg_stat_activity WHERE pid <> pg_backend_pid( ) AND datname = 'cirrasdev'; //WHERE cirrasdev is the old database name
2 changes: 1 addition & 1 deletion openshift/cirras-underwriting-api-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data:
WEBADE_USERNAME: '#{WEBADE_USERNAME}#'
CIRRAS_UNDERWRITING_REST_SECRET: '#{CIRRAS_UNDERWRITING_REST_SECRET}#'
POSTGRES_URL: >-
jdbc:postgresql://crunchy-postgres-#{ENV}#-pgbouncer.#{NAMESPACE}#.svc.cluster.local/cirras#{ENV}#
jdbc:postgresql://crunchy-postgres-#{ENV}#-pgbouncer.#{NAMESPACE}#.svc.cluster.local/pituw#{ENV}#
WEBADE_PASSWORD: '#{WEBADE_PASSWORD}#'
WEBADE_GET_TOKEN_URL: '#{WEBADE_GET_TOKEN_URL}#'
WEBADE_OAUTH2_AUTHORIZE_URL: '#{WEBADE_OAUTH2_AUTHORIZE_URL}#'
Expand Down
2 changes: 1 addition & 1 deletion openshift/cirras-underwriting-liquibase-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ immutable: false
data:
LIQUIBASE_COMMAND_USERNAME: '#{POSTGRES_ADMIN_USERNAME}#'
LIQUIBASE_COMMAND_PASSWORD: '#{POSTGRES_ADMIN_PASSWORD}#'
LIQUIBASE_COMMAND_URL: jdbc:postgresql://crunchy-postgres-#{ENV}#-pgbouncer.#{NAMESPACE}#.svc.cluster.local/cirras#{ENV}#
LIQUIBASE_COMMAND_URL: jdbc:postgresql://crunchy-postgres-#{ENV}#-pgbouncer.#{NAMESPACE}#.svc.cluster.local/pituw#{ENV}#
POSTGRES_PROXY_USER_PASSWORD: '#{POSTGRES_PROXY_USER_PASSWORD}#'
POSTGRES_READ_ONLY_PASSWORD: '#{POSTGRES_READ_ONLY_PASSWORD}#'

0 comments on commit d8277af

Please sign in to comment.