Skip to content

Deployment Process

Alejandro Sanchez edited this page Sep 8, 2021 · 3 revisions

Manual DB migration

In any case where it is not possible to do an automated migration via EF, the target database must be wiped, and the keycloak sync tool must be ran against the new environment to ensure that the database is up to date with the code changes. Note that the following steps must be executed in the order presented here.

Wipe Database (using SSMS)

  1. Login to the appropriate database for the deployment, this may require vpn.
  2. Open a new query editor window within the target database.
  3. Copy the script stored here: https://raw.githubusercontent.com/bcgov/PSP/dev/database/mssql/scripts/clear-objects.sql and paste into the query editor
  4. Execute the script.
  5. Validate that all tables and db objects have been removed in SSMS.

Run the Migration

  1. In order to complete this step, you must have the PSP repository checked out locally on your device. See the developer setup documentation for more details on this.
  2. Update (or create) the .env file located in <PSP_ROOT>/backend/dal. Replace the <> values below with appropriate values for the target environment.
ConnectionStrings__PIMS=Server=<PIMS_SERVER_NAME>,<PORT>;Database=<PIMS_DATABASE_NAME>;User Id=<PIMS_USERNAME>
DB_PASSWORD=<PIMS_DB_PASSWORD>
  1. Open a terminal within the root of the PSP repository. Execute make db-update. This should execute the migration(s) against the database.
  2. Validate that the expected DB objects were created as a result of running the script (at least verify the tables exist).

Run the Keycloak sync tool

  1. In order to complete this step, you must have the PSP repository checked out locally on your device. See the developer setup documentation for more details on this.
  2. Update (or create) the .env file located in <PSP_ROOT>/tools/keycloak/sync. Replace the <> values below with appropriate values for the target environment. Alternatively update the appsettings.{env}.json file to point to the correct URLs for this environment.
ASPNETCORE_ENVIRONMENT=<EITHER_Development_Test_OR_UNSET>
Auth__Keycloak__Secret=<SECRET_FROM_PIMS_SERVICE_ACCOUNT_IN_THIS_ENVIRONMENT>
  1. Open a terminal within the root of the PSP repository. execute make keycloak-sync. This should synchronize the PSP database with keycloak.
Clone this wiki locally