Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BHBC-1249 #442

Merged
merged 20 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
93ee4a7
BHBC-1173
Jun 30, 2021
1f24712
Merge branch 'dev' of https://github.com/bcgov/biohubbc into dev
Jul 7, 2021
bd520b4
Merge branch 'dev' of https://github.com/bcgov/biohubbc into dev
Jul 9, 2021
f3d47e4
Merge branch 'dev' of https://github.com/bcgov/biohubbc into dev
Jul 13, 2021
b0ac320
Merge branch 'dev' of https://github.com/bcgov/biohubbc into dev
Jul 21, 2021
a22ec4c
Merge branch 'dev' of https://github.com/bcgov/biohubbc into dev
Aug 5, 2021
651fb0e
Merge branch 'dev' of https://github.com/bcgov/biohubbc into dev
Aug 5, 2021
9e540b5
BHBC-1249
Aug 5, 2021
4b9dadc
BHBC-1249
Aug 5, 2021
65e4788
Merge branch 'BHBC-1249' of https://github.com/bcgov/biohubbc into BH…
Aug 5, 2021
2fd98b8
Merge branch 'BHBC-1249' of https://github.com/bcgov/biohubbc into BH…
Aug 5, 2021
ab9f7c9
- minor fix to migration mainline
Aug 5, 2021
bd6672d
Merge branch 'BHBC-1249' of https://github.com/bcgov/biohubbc into BH…
Aug 5, 2021
784be1e
Merge branch 'BHBC-1249' of https://github.com/bcgov/biohubbc into BH…
Aug 5, 2021
258af14
Merge branch 'BHBC-1249' of https://github.com/bcgov/biohubbc into BH…
Aug 5, 2021
5f3006a
- problems with passing xml types back to api. sticking with charac…
Aug 5, 2021
f86e7be
- fixed problem with icun levels not reporting properly
Aug 6, 2021
bd3b810
Merge branch 'dev' into BHBC-1249
sdevalapurkar Aug 6, 2021
3a11bd1
Merge branch 'dev' into BHBC-1249
anissa-agahchen Aug 9, 2021
65b210f
Merge branch 'dev' into BHBC-1249
anissa-agahchen Aug 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion database/src/migrations/20210225205948_biohub_release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'path';
const DB_USER_API_PASS = process.env.DB_USER_API_PASS;
const DB_USER_API = process.env.DB_USER_API;

const DB_RELEASE = 'release.0.21';
const DB_RELEASE = 'release.0.22';

/**
* Apply biohub release changes.
Expand Down Expand Up @@ -37,14 +37,20 @@ export async function up(knex: Knex): Promise<void> {
const tr_project = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'tr_project.sql'));
const tr_survey = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'tr_survey.sql'));
const tr_permit = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'tr_permit.sql'));
const tr_occurrence_submission = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'tr_occurrence_submission.sql'));
const api_get_system_constant = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'api_get_system_constant.sql'));
const api_get_system_metadata_constant = fs.readFileSync(
path.join(__dirname, DB_RELEASE, 'api_get_system_metadata_constant.sql')
);
const vw_survey_status = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'vw_survey_status.sql'));

const api_delete_occurrence_submission = fs.readFileSync(
path.join(__dirname, DB_RELEASE, 'api_delete_occurrence_submission.sql')
);
const api_delete_survey = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'api_delete_survey.sql'));
const api_delete_project = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'api_delete_project.sql'));
const api_xml_string_replace = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'api_xml_string_replace.sql'));
const api_get_eml_data_package = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'api_get_eml_data_package.sql'));

const populate_system_constants = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'populate_system_constant.sql'));
const populate_first_nations = fs.readFileSync(path.join(__dirname, DB_RELEASE, 'populate_first_nations.sql'));
Expand Down Expand Up @@ -133,12 +139,16 @@ export async function up(knex: Knex): Promise<void> {
${tr_project}
${tr_survey}
${tr_permit}
${tr_occurrence_submission}
${api_get_system_constant}
${api_get_system_metadata_constant}
${vw_survey_status}

${api_delete_occurrence_submission}
${api_delete_survey}
${api_delete_project}
${api_xml_string_replace}
${api_get_eml_data_package}

-- populate look up tables
set search_path = biohub;
Expand Down

This file was deleted.

This file was deleted.

73 changes: 0 additions & 73 deletions database/src/migrations/20210803170006_remove_project_region.ts

This file was deleted.

45 changes: 0 additions & 45 deletions database/src/migrations/release.0.21/api_delete_project.sql

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ begin
select exists into _is_published (select 1 from survey_status ss, occurrence_submission os
where os.occurrence_submission_id = _occurrence_submission_id
and ss.survey_id = os.survey_id
and ss.survey_status = (select api_get_character_system_constant('SURVEY_STATE_PUBLISHED')));
and ss.survey_status = (select api_get_character_system_constant('OCCURRENCE_SUBMISSION_STATE_PUBLISHED')));

if _is_published then
select api_user_is_administrator() into _is_system_administrator;
Expand All @@ -36,6 +36,8 @@ begin
delete from submission_message where submission_status_id in (select submission_status_id from submission_status where occurrence_submission_id = _occurrence_submission_id);
delete from submission_status where occurrence_submission_id = _occurrence_submission_id;
delete from occurrence where occurrence_submission_id = _occurrence_submission_id;
delete from occurrence_submission_data_package where occurrence_submission_id = _occurrence_submission_id;
delete from data_package where data_package_id in (select data_package_id from occurrence_submission_data_package where occurrence_submission_id = _occurrence_submission_id);
delete from occurrence_submission where occurrence_submission_id = _occurrence_submission_id;

exception
Expand Down
44 changes: 44 additions & 0 deletions database/src/migrations/release.0.22/api_delete_project.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- api_delete_project.sql
drop procedure if exists api_delete_project;

create or replace procedure api_delete_project(p_project_id project.project_id%type)
language plpgsql
security definer
as
$$
-- *******************************************************************
-- Procedure: api_delete_project
-- Purpose: deletes a project and dependencies
--
-- MODIFICATION HISTORY
-- Person Date Comments
-- ---------------- ----------- --------------------------------------
-- [email protected]
-- 2021-04-19 initial release
-- 2021-06-21 added delete survey
-- *******************************************************************
declare
_survey_id survey.survey_id%type;
begin
for _survey_id in (select survey_id from survey where project_id = p_project_id) loop
call api_delete_survey(_survey_id);
end loop;

delete from permit where project_id = p_project_id;
delete from survey where project_id = p_project_id;
delete from stakeholder_partnership where project_id = p_project_id;
delete from project_activity where project_id = p_project_id;
delete from project_climate_initiative where project_id = p_project_id;
delete from project_management_actions where project_id = p_project_id;
delete from project_funding_source where project_id = p_project_id;
delete from project_iucn_action_classification where project_id = p_project_id;
delete from project_attachment where project_id = p_project_id;
delete from project_first_nation where project_id = p_project_id;
delete from project_participation where project_id = p_project_id;
delete from project where project_id = p_project_id;

exception
when others THEN
raise;
end;
$$;
Loading