Skip to content

Commit

Permalink
Release Dev to Test - Merge pull request #1315 from bcgov/dev
Browse files Browse the repository at this point in the history
Release Dev to Test
  • Loading branch information
NickPhura authored Jun 26, 2024
2 parents 2e6cc66 + ce03ca4 commit 56bf843
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 23 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches-ignore:
- test
- prod

concurrency:
Expand Down
23 changes: 0 additions & 23 deletions database/src/migrations/20240624000000_attachment_type_fix.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Knex } from 'knex';

/**
* Drop deprecated study_species.wldtaxonomic_units_id column.
* Drop deprecated survey.field_method_id column.
*
* Migrate outdated project_attachment.file_type and survey_attachment.file_type values:
* - Deprecated values 'Spatial Data' and 'Data File' are now 'Other'.
*
Expand All @@ -13,34 +10,14 @@ import { Knex } from 'knex';
*/
export async function up(knex: Knex): Promise<void> {
await knex.raw(`--sql
----------------------------------------------------------------------------------------
-- Drop views
----------------------------------------------------------------------------------------
SET SEARCH_PATH=biohub_dapi_v1;
DROP VIEW IF EXISTS study_species;
DROP VIEW IF EXISTS survey;
----------------------------------------------------------------------------------------
-- Alter tables/data
----------------------------------------------------------------------------------------
SET SEARCH_PATH=biohub;
-- Drop deprecated columns
ALTER TABLE study_species DROP COLUMN wldtaxonomic_units_id;
ALTER TABLE survey DROP COLUMN field_method_id;
-- Migrate deprecated file_type values
UPDATE project_attachment SET file_type = 'Other' WHERE file_type NOT IN ('Other', 'KeyX', 'Report');
UPDATE survey_attachment SET file_type = 'Other' WHERE file_type NOT IN ('Other', 'KeyX', 'Report');
----------------------------------------------------------------------------------------
-- Update views
----------------------------------------------------------------------------------------
SET SEARCH_PATH=biohub_dapi_v1;
CREATE OR REPLACE VIEW study_species as SELECT * FROM biohub.study_species;
CREATE OR REPLACE VIEW survey as SELECT * FROM biohub.survey;
`);
}

Expand Down
50 changes: 50 additions & 0 deletions database/src/migrations/20240625000000_deprecated_columns.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Knex } from 'knex';

/**
* Drop deprecated study_species.wldtaxonomic_units_id column.
* Drop deprecated survey_observation.wldtaxonomic_units_id column.
* Drop deprecated survey.field_method_id column.
*
* @export
* @param {Knex} knex
* @return {*} {Promise<void>}
*/
export async function up(knex: Knex): Promise<void> {
await knex.raw(`--sql
----------------------------------------------------------------------------------------
-- Drop views
----------------------------------------------------------------------------------------
SET SEARCH_PATH=biohub_dapi_v1;
DROP VIEW IF EXISTS study_species;
DROP VIEW IF EXISTS survey_observation;
DROP VIEW IF EXISTS survey;
----------------------------------------------------------------------------------------
-- Alter tables/data
----------------------------------------------------------------------------------------
SET SEARCH_PATH=biohub;
-- Drop deprecated wldtaxonomic_units_id column
ALTER TABLE study_species DROP COLUMN IF EXISTS wldtaxonomic_units_id;
ALTER TABLE survey_observation DROP COLUMN IF EXISTS wldtaxonomic_units_id;
-- Drop deprecated field_method_id column
ALTER TABLE survey DROP COLUMN IF EXISTS field_method_id;
----------------------------------------------------------------------------------------
-- Update views
----------------------------------------------------------------------------------------
SET SEARCH_PATH=biohub_dapi_v1;
CREATE OR REPLACE VIEW study_species as SELECT * FROM biohub.study_species;
CREATE OR REPLACE VIEW survey_observation as SELECT * FROM biohub.survey_observation;
CREATE OR REPLACE VIEW survey as SELECT * FROM biohub.survey;
`);
}

export async function down(knex: Knex): Promise<void> {
await knex.raw(``);
}

0 comments on commit 56bf843

Please sign in to comment.