-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release Dev to Test - Merge pull request #1315 from bcgov/dev
Release Dev to Test
- Loading branch information
Showing
3 changed files
with
51 additions
and
23 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
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
50 changes: 50 additions & 0 deletions
50
database/src/migrations/20240625000000_deprecated_columns.ts
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,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(``); | ||
} |