Skip to content

Commit

Permalink
SIMSBIOHUB-449: Upgrade to Postgres 17 (#1428)
Browse files Browse the repository at this point in the history
- Upgrade Postgres from 12.5 to 17-bullseye
- Wrap most instances of "system_user" in double quotes, as it is not a reserved word in postgres.
- Add migration to drop biohub_dapi_v1 schema
- Disable static deploy db setup step
- Delete deprecated custom postgres image
- Remove user name search path
  • Loading branch information
NickPhura authored Jan 15, 2025
1 parent 4e00fba commit 6ae74e0
Show file tree
Hide file tree
Showing 72 changed files with 476 additions and 1,673 deletions.
114 changes: 57 additions & 57 deletions .github/workflows/deployStatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,62 +431,62 @@ jobs:
DEBUG=* npm run db:deploy -- --pr=$PR_NUMBER --env=$BRANCH --branch=$BRANCH --type=static
# Deploy Database setup image
deployDatabaseSetup:
name: Deploy Database Setup Image
runs-on: ubuntu-latest
timeout-minutes: 30
if: ${{ github.event.pull_request.merged == true }}
env:
PR_NUMBER: ${{ github.event.number }}
BRANCH: ${{ github.base_ref }}
needs:
- scaleDownPods
- buildDatabaseSetup
- deployDatabase
steps:
# Install Node - for `node` and `npm` commands
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

# Load repo from cache
- name: Cache repo
uses: actions/cache@v4
id: cache-repo
env:
cache-name: cache-repo
with:
path: ${{ github.workspace }}/*
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}

# Checkout the branch if not restored via cache
- name: Checkout Target Branch
if: steps.cache-repo.outputs.cache-hit != 'true'
uses: actions/checkout@v4

# Install oc, which was removed from the ubuntu-latest image in v24.04
- name: Install OpenShift CLI tools
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.14"

# Log in to OpenShift.
# Note: The secrets needed to log in are NOT available if the PR comes from a FORK.
# PR's must originate from a branch off the original repo or else all openshift `oc` commands will fail.
- name: Log in to OpenShift
run: oc login --token=${{ secrets.TOOLS_SA_TOKEN }} --server=https://api.silver.devops.gov.bc.ca:6443

# Install database pipeline node modules
- name: Install database pipeline node modules
working-directory: "database/.pipeline/"
run: npm ci

# Deploy the database setup image
- name: Deploy Database Setup Image
working-directory: "database/.pipeline/"
run: |
DEBUG=* npm run db-setup:deploy -- --pr=$PR_NUMBER --env=$BRANCH --branch=$BRANCH --type=static
# deployDatabaseSetup:
# name: Deploy Database Setup Image
# runs-on: ubuntu-latest
# timeout-minutes: 30
# if: ${{ github.event.pull_request.merged == true }}
# env:
# PR_NUMBER: ${{ github.event.number }}
# BRANCH: ${{ github.base_ref }}
# needs:
# - scaleDownPods
# - buildDatabaseSetup
# - deployDatabase
# steps:
# # Install Node - for `node` and `npm` commands
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 20

# # Load repo from cache
# - name: Cache repo
# uses: actions/cache@v4
# id: cache-repo
# env:
# cache-name: cache-repo
# with:
# path: ${{ github.workspace }}/*
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}

# # Checkout the branch if not restored via cache
# - name: Checkout Target Branch
# if: steps.cache-repo.outputs.cache-hit != 'true'
# uses: actions/checkout@v4

# # Install oc, which was removed from the ubuntu-latest image in v24.04
# - name: Install OpenShift CLI tools
# uses: redhat-actions/openshift-tools-installer@v1
# with:
# oc: "4.14"

# # Log in to OpenShift.
# # Note: The secrets needed to log in are NOT available if the PR comes from a FORK.
# # PR's must originate from a branch off the original repo or else all openshift `oc` commands will fail.
# - name: Log in to OpenShift
# run: oc login --token=${{ secrets.TOOLS_SA_TOKEN }} --server=https://api.silver.devops.gov.bc.ca:6443

# # Install database pipeline node modules
# - name: Install database pipeline node modules
# working-directory: "database/.pipeline/"
# run: npm ci

# # Deploy the database setup image
# - name: Deploy Database Setup Image
# working-directory: "database/.pipeline/"
# run: |
# DEBUG=* npm run db-setup:deploy -- --pr=$PR_NUMBER --env=$BRANCH --branch=$BRANCH --type=static

# Deploy API image
deployAPI:
Expand Down Expand Up @@ -554,7 +554,7 @@ jobs:
if: ${{ github.event.pull_request.merged == true }}
needs:
- deployDatabase
- deployDatabaseSetup
# - deployDatabaseSetup
- deployAPI
- deployAPP
env:
Expand Down
4 changes: 2 additions & 2 deletions api/src/repositories/administrative-activity-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class AdministrativeActivityRepository extends BaseRepository {
ON
aa.administrative_activity_type_id = aat.administrative_activity_type_id
LEFT OUTER JOIN
system_user su
"system_user" su
ON
su.system_user_id = aa.update_user
WHERE
Expand Down Expand Up @@ -223,7 +223,7 @@ export class AdministrativeActivityRepository extends BaseRepository {
FROM
project_participation pp
LEFT JOIN
system_user su
"system_user" su
ON
pp.system_user_id = su.system_user_id
WHERE
Expand Down
6 changes: 3 additions & 3 deletions api/src/repositories/project-participation-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class ProjectParticipationRepository extends BaseRepository {
ON pp.project_role_id = prp.project_role_id
LEFT JOIN project_permission pp2
ON pp2.project_permission_id = prp.project_permission_id
LEFT JOIN system_user su
LEFT JOIN "system_user" su
ON pp.system_user_id = su.system_user_id
LEFT JOIN
system_user_role sur
Expand Down Expand Up @@ -365,7 +365,7 @@ export class ProjectParticipationRepository extends BaseRepository {
ON pp.project_role_id = prp.project_role_id
LEFT JOIN project_permission pp2
ON pp2.project_permission_id = prp.project_permission_id
LEFT JOIN system_user su
LEFT JOIN "system_user" su
ON pp.system_user_id = su.system_user_id
LEFT JOIN
system_user_role sur
Expand Down Expand Up @@ -503,7 +503,7 @@ export class ProjectParticipationRepository extends BaseRepository {
ON pp.project_role_id = prp.project_role_id
LEFT JOIN project_permission pp2
ON pp2.project_permission_id = prp.project_permission_id
LEFT JOIN system_user su
LEFT JOIN "system_user" su
ON pp.system_user_id = su.system_user_id
LEFT JOIN
system_user_role sur
Expand Down
4 changes: 2 additions & 2 deletions api/src/repositories/survey-participation-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class SurveyParticipationRepository extends BaseRepository {
LEFT JOIN
survey_job sj
ON sj.survey_job_id = sp.survey_job_id
LEFT JOIN system_user su
LEFT JOIN "system_user" su
ON sp.system_user_id = su.system_user_id
LEFT JOIN
system_user_role sur
Expand Down Expand Up @@ -192,7 +192,7 @@ export class SurveyParticipationRepository extends BaseRepository {
LEFT JOIN
survey_job sj
ON sj.survey_job_id = sp.survey_job_id
LEFT JOIN system_user su
LEFT JOIN "system_user" su
ON sp.system_user_id = su.system_user_id
LEFT JOIN
system_user_role sur
Expand Down
14 changes: 7 additions & 7 deletions api/src/repositories/user-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class UserRepository extends BaseRepository {
su.family_name,
su.agency
FROM
system_user su
"system_user" su
LEFT JOIN
system_user_role sur
ON
Expand Down Expand Up @@ -147,7 +147,7 @@ export class UserRepository extends BaseRepository {
su.family_name,
su.agency
FROM
system_user su
"system_user" su
LEFT JOIN
system_user_role sur
ON
Expand Down Expand Up @@ -205,7 +205,7 @@ export class UserRepository extends BaseRepository {
su.family_name,
su.agency
FROM
system_user su
"system_user" su
LEFT JOIN
system_user_role sur
ON
Expand Down Expand Up @@ -264,7 +264,7 @@ export class UserRepository extends BaseRepository {
): Promise<{ system_user_id: number }> {
const sqlStatement = SQL`
INSERT INTO
system_user
"system_user"
(
user_guid,
user_identity_source_id,
Expand Down Expand Up @@ -328,7 +328,7 @@ export class UserRepository extends BaseRepository {
su.family_name,
su.agency
FROM
system_user su
"system_user" su
LEFT JOIN
system_user_role sur
ON
Expand Down Expand Up @@ -369,7 +369,7 @@ export class UserRepository extends BaseRepository {
async activateSystemUser(systemUserId: number) {
const sqlStatement = SQL`
UPDATE
system_user
"system_user"
SET
record_end_date = NULL
WHERE
Expand Down Expand Up @@ -401,7 +401,7 @@ export class UserRepository extends BaseRepository {
async deactivateSystemUser(systemUserId: number) {
const sqlStatement = SQL`
UPDATE
system_user
"system_user"
SET
record_end_date = now()
WHERE
Expand Down
3 changes: 2 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ services:
- POSTGRES_PASSWORD=${DB_ADMIN_PASS}
- POSTGRES_DB=${DB_DATABASE}
- PORT=5432
- PGDATA=${PGDATA}/${POSTGRES_VERSION}
networks:
- sims-network
volumes:
- postgres:/var/lib/postgresql/data
- postgres:${PGDATA}

## Build the api docker image
api:
Expand Down
8 changes: 0 additions & 8 deletions containers/postgres12-postgis31/.gitattributes

This file was deleted.

7 changes: 0 additions & 7 deletions containers/postgres12-postgis31/.gitignore

This file was deleted.

Loading

0 comments on commit 6ae74e0

Please sign in to comment.