diff --git a/api/src/paths/codes.ts b/api/src/paths/codes.ts index c0c28a51de..bf28d30fdf 100644 --- a/api/src/paths/codes.ts +++ b/api/src/paths/codes.ts @@ -178,7 +178,7 @@ GET.apiDoc = { id: { type: 'number' }, - iucn_id: { + iucn1_id: { type: 'number' }, name: { @@ -195,7 +195,7 @@ GET.apiDoc = { id: { type: 'number' }, - iucn1_id: { + iucn2_id: { type: 'number' }, name: { diff --git a/api/src/paths/project.ts b/api/src/paths/project.ts index 2a0bb039e2..c3f841cd4a 100644 --- a/api/src/paths/project.ts +++ b/api/src/paths/project.ts @@ -354,11 +354,11 @@ export const insertPermitNumber = async ( }; export const insertClassificationDetail = async ( - iucn_id: number, + iucn3_id: number, project_id: number, connection: IDBConnection ): Promise => { - const sqlStatement = postProjectIUCNSQL(iucn_id, project_id); + const sqlStatement = postProjectIUCNSQL(iucn3_id, project_id); if (!sqlStatement) { throw new CustomError(400, 'Failed to build SQL statement'); diff --git a/api/src/queries/code-queries.ts b/api/src/queries/code-queries.ts index ae1e82988d..f8be2005a7 100644 --- a/api/src/queries/code-queries.ts +++ b/api/src/queries/code-queries.ts @@ -64,7 +64,7 @@ export const getIUCNConservationActionLevel1ClassificationSQL = (): SQLStatement * @returns {SQLStatement} sql query object */ export const getIUCNConservationActionLevel2SubclassificationSQL = (): SQLStatement => - SQL`SELECT id, iucn_id, name from iucn_conservation_action_level_2_subclassification;`; + SQL`SELECT id, iucn1_id, name from iucn_conservation_action_level_2_subclassification;`; /** * SQL query to fetch IUCN conservation action level 3 sub-classification codes. @@ -72,4 +72,4 @@ export const getIUCNConservationActionLevel2SubclassificationSQL = (): SQLStatem * @returns {SQLStatement} sql query object */ export const getIUCNConservationActionLevel3SubclassificationSQL = (): SQLStatement => - SQL`SELECT id, iucn1_id, name from iucn_conservation_action_level_3_subclassification;`; + SQL`SELECT id, iucn2_id, name from iucn_conservation_action_level_3_subclassification;`; diff --git a/api/src/queries/project-queries.ts b/api/src/queries/project-queries.ts index 11059de0a3..392ae55034 100644 --- a/api/src/queries/project-queries.ts +++ b/api/src/queries/project-queries.ts @@ -691,19 +691,19 @@ export const getIUCNActionClassificationByProjectSQL = (projectId: number): SQLS ical2s.name as subClassification1, ical3s.name as subClassification2 FROM - project_iucn_action_classificaton as piac + project_iucn_action_classification as piac LEFT OUTER JOIN iucn_conservation_action_level_3_subclassification as ical3s ON - piac.iucn2_id = ical3s.id + piac.iucn3_id = ical3s.id LEFT OUTER JOIN iucn_conservation_action_level_2_subclassification as ical2s ON - ical3s.iucn1_id = ical2s.id + ical3s.iucn2_id = ical2s.id LEFT OUTER JOIN iucn_conservation_action_level_1_classification as ical1c ON - ical2s.iucn_id = ical1c.id + ical2s.iucn1_id = ical1c.id WHERE piac.p_id = ${projectId} GROUP BY @@ -777,28 +777,28 @@ export const getFundingSourceByProjectSQL = (projectId: number): SQLStatement | /** * SQL query to insert a project IUCN row. * - * @param iucn_id + * @param iucn3_id * @param project_id * @returns {SQLStatement} sql query object */ -export const postProjectIUCNSQL = (iucn_id: number, project_id: number): SQLStatement | null => { +export const postProjectIUCNSQL = (iucn3_id: number, project_id: number): SQLStatement | null => { defaultLog.debug({ label: 'postProjectIUCNSQL', message: 'params', - iucn_id, + iucn3_id, project_id }); - if (!iucn_id || !project_id) { + if (!iucn3_id || !project_id) { return null; } const sqlStatement: SQLStatement = SQL` - INSERT INTO project_iucn_action_classificaton ( - iucn2_id, + INSERT INTO project_iucn_action_classification ( + iucn3_id, p_id ) VALUES ( - ${iucn_id}, + ${iucn3_id}, ${project_id} ) RETURNING diff --git a/app/src/features/projects/CreateProjectPage.tsx b/app/src/features/projects/CreateProjectPage.tsx index ca45161a36..be54e20e93 100644 --- a/app/src/features/projects/CreateProjectPage.tsx +++ b/app/src/features/projects/CreateProjectPage.tsx @@ -291,12 +291,12 @@ const CreateProjectPage: React.FC = () => { } subClassifications1={ codes?.iucn_conservation_action_level_2_subclassification?.map((item) => { - return { value: item.id, iucn_id: item.iucn_id, label: item.name }; + return { value: item.id, iucn1_id: item.iucn1_id, label: item.name }; }) || [] } subClassifications2={ codes?.iucn_conservation_action_level_3_subclassification?.map((item) => { - return { value: item.id, iucn1_id: item.iucn1_id, label: item.name }; + return { value: item.id, iucn2_id: item.iucn2_id, label: item.name }; }) || [] } /> diff --git a/app/src/features/projects/components/ProjectIUCNForm.test.tsx b/app/src/features/projects/components/ProjectIUCNForm.test.tsx index 90b13fc361..a52e467461 100644 --- a/app/src/features/projects/components/ProjectIUCNForm.test.tsx +++ b/app/src/features/projects/components/ProjectIUCNForm.test.tsx @@ -24,12 +24,12 @@ const classifications: IMultiAutocompleteFieldOption[] = [ const subClassifications1: IIUCNSubClassification1Option[] = [ { value: 3, - iucn_id: 1, + iucn1_id: 1, label: 'A Sub-class 1' }, { value: 4, - iucn_id: 2, + iucn1_id: 2, label: 'A Sub-class 1 again' } ]; @@ -37,12 +37,12 @@ const subClassifications1: IIUCNSubClassification1Option[] = [ const subClassifications2: IIUCNSubClassification2Option[] = [ { value: 5, - iucn1_id: 3, + iucn2_id: 3, label: 'A Sub-class 2' }, { value: 6, - iucn1_id: 4, + iucn2_id: 4, label: 'A Sub-class 2 again' } ]; diff --git a/app/src/features/projects/components/ProjectIUCNForm.tsx b/app/src/features/projects/components/ProjectIUCNForm.tsx index 00afcc8def..d157410462 100644 --- a/app/src/features/projects/components/ProjectIUCNForm.tsx +++ b/app/src/features/projects/components/ProjectIUCNForm.tsx @@ -49,11 +49,11 @@ export const ProjectIUCNFormInitialValues: IProjectIUCNForm = { }; export interface IIUCNSubClassification1Option extends IMultiAutocompleteFieldOption { - iucn_id: number; + iucn1_id: number; } export interface IIUCNSubClassification2Option extends IMultiAutocompleteFieldOption { - iucn1_id: number; + iucn2_id: number; } export const ProjectIUCNFormYupSchema = yup.object().shape({ @@ -141,7 +141,7 @@ const ProjectIUCNForm: React.FC = (props) => { inputProps={{ 'aria-label': 'subClassification1' }}> {props.subClassifications1 // Only show the sub-classification 1 categories whose iucn_id matches the classification id - .filter((item: any) => item.iucn_id === classificationDetail.classification) + .filter((item: any) => item.iucn1_id === classificationDetail.classification) .map((item: any) => ( {item.label} @@ -166,7 +166,7 @@ const ProjectIUCNForm: React.FC = (props) => { inputProps={{ 'aria-label': 'subClassification2' }}> {props.subClassifications2 // Only show the sub-classification 2 categories whose iucn1_id matches the sub-classification 1 iucn_id - .filter((item: any) => item.iucn1_id === classificationDetail.subClassification1) + .filter((item: any) => item.iucn2_id === classificationDetail.subClassification1) .map((item: any) => ( {item.label} diff --git a/app/src/interfaces/useBioHubApi-interfaces.ts b/app/src/interfaces/useBioHubApi-interfaces.ts index ebab0061f6..5dc4b83b33 100644 --- a/app/src/interfaces/useBioHubApi-interfaces.ts +++ b/app/src/interfaces/useBioHubApi-interfaces.ts @@ -165,6 +165,6 @@ export interface IGetAllCodesResponse { region: ICodeSet; species: ICodeSet; iucn_conservation_action_level_1_classification: ICodeSet; - iucn_conservation_action_level_2_subclassification: ICodeSet<{ id: number; iucn_id: number; name: string }>; - iucn_conservation_action_level_3_subclassification: ICodeSet<{ id: number; iucn1_id: number; name: string }>; + iucn_conservation_action_level_2_subclassification: ICodeSet<{ id: number; iucn1_id: number; name: string }>; + iucn_conservation_action_level_3_subclassification: ICodeSet<{ id: number; iucn2_id: number; name: string }>; } diff --git a/database/src/migrations/20210225205948_biohub_release_0.7.ts b/database/src/migrations/20210225205948_biohub_release_0.8.ts similarity index 74% rename from database/src/migrations/20210225205948_biohub_release_0.7.ts rename to database/src/migrations/20210225205948_biohub_release_0.8.ts index bd7c0f4fd2..ff7b0264d9 100644 --- a/database/src/migrations/20210225205948_biohub_release_0.7.ts +++ b/database/src/migrations/20210225205948_biohub_release_0.8.ts @@ -6,7 +6,7 @@ const DB_USER_API_PASS = process.env.DB_USER_API_PASS; const DB_USER_API = process.env.DB_USER_API; /** - * Apply biohub release 0.7 changes. + * Apply biohub release changes. * * @export * @param {Knex} knex @@ -14,40 +14,40 @@ const DB_USER_API = process.env.DB_USER_API; */ export async function up(knex: Knex): Promise { const create_spatial_extensions = fs.readFileSync( - path.join(__dirname, 'release.0.7', 'create_spatial_extensions.psql') + path.join(__dirname, 'release.0.8', 'create_spatial_extensions.psql') ); - const biohub_0_7 = fs.readFileSync(path.join(__dirname, 'release.0.7', 'biohub.0.7.sql')); + const biohub_ddl = fs.readFileSync(path.join(__dirname, 'release.0.8', 'biohub.sql')); const populate_user_identity_source = fs.readFileSync( - path.join(__dirname, 'release.0.7', 'populate_user_identity_source.sql') + path.join(__dirname, 'release.0.8', 'populate_user_identity_source.sql') ); - const api_set_context = fs.readFileSync(path.join(__dirname, 'release.0.7', 'api_set_context.sql')); - const tr_audit_trigger = fs.readFileSync(path.join(__dirname, 'release.0.7', 'tr_audit_trigger.sql')); - const project_audit_triggers = fs.readFileSync(path.join(__dirname, 'release.0.7', 'project_audit_triggers.sql')); - const api_get_context_user_id = fs.readFileSync(path.join(__dirname, 'release.0.7', 'api_get_context_user_id.sql')); - const tr_journal_trigger = fs.readFileSync(path.join(__dirname, 'release.0.7', 'tr_journal_trigger.sql')); - const project_journal_triggers = fs.readFileSync(path.join(__dirname, 'release.0.7', 'project_journal_triggers.sql')); + const api_set_context = fs.readFileSync(path.join(__dirname, 'release.0.8', 'api_set_context.sql')); + const tr_audit_trigger = fs.readFileSync(path.join(__dirname, 'release.0.8', 'tr_audit_trigger.sql')); + const project_audit_triggers = fs.readFileSync(path.join(__dirname, 'release.0.8', 'project_audit_triggers.sql')); + const api_get_context_user_id = fs.readFileSync(path.join(__dirname, 'release.0.8', 'api_get_context_user_id.sql')); + const tr_journal_trigger = fs.readFileSync(path.join(__dirname, 'release.0.8', 'tr_journal_trigger.sql')); + const project_journal_triggers = fs.readFileSync(path.join(__dirname, 'release.0.8', 'project_journal_triggers.sql')); const tr_project_funding_source = fs.readFileSync( - path.join(__dirname, 'release.0.7', 'tr_project_funding_source.sql') + path.join(__dirname, 'release.0.8', 'tr_project_funding_source.sql') ); - const populate_first_nations = fs.readFileSync(path.join(__dirname, 'release.0.7', 'populate_first_nations.sql')); + const populate_first_nations = fs.readFileSync(path.join(__dirname, 'release.0.8', 'populate_first_nations.sql')); const populate_climate_change_initiatives = fs.readFileSync( - path.join(__dirname, 'release.0.7', 'populate_climate_change_initiatives.sql') + path.join(__dirname, 'release.0.8', 'populate_climate_change_initiatives.sql') ); const populate_management_action_type = fs.readFileSync( - path.join(__dirname, 'release.0.7', 'populate_management_action_type.sql') + path.join(__dirname, 'release.0.8', 'populate_management_action_type.sql') ); - const populate_funding_source = fs.readFileSync(path.join(__dirname, 'release.0.7', 'populate_funding_source.sql')); + const populate_funding_source = fs.readFileSync(path.join(__dirname, 'release.0.8', 'populate_funding_source.sql')); const populate_investment_action_category = fs.readFileSync( - path.join(__dirname, 'release.0.7', 'populate_investment_action_category.sql') + path.join(__dirname, 'release.0.8', 'populate_investment_action_category.sql') ); - const populate_project_type = fs.readFileSync(path.join(__dirname, 'release.0.7', 'populate_project_type.sql')); - const populate_activity = fs.readFileSync(path.join(__dirname, 'release.0.7', 'populate_activity.sql')); + const populate_project_type = fs.readFileSync(path.join(__dirname, 'release.0.8', 'populate_project_type.sql')); + const populate_activity = fs.readFileSync(path.join(__dirname, 'release.0.8', 'populate_activity.sql')); const populate_icun_classifications = fs.readFileSync( - path.join(__dirname, 'release.0.7', 'populate_icun_classifications.sql') + path.join(__dirname, 'release.0.8', 'populate_icun_classifications.sql') ); - const project_dapi_views = fs.readFileSync(path.join(__dirname, 'release.0.7', 'project_dapi_views.sql')); + const project_dapi_views = fs.readFileSync(path.join(__dirname, 'release.0.8', 'project_dapi_views.sql')); await knex.raw(` -- set up spatial extensions @@ -57,7 +57,7 @@ export async function up(knex: Knex): Promise { create schema if not exists biohub; set search_path = biohub, public; - ${biohub_0_7} + ${biohub_ddl} ${populate_user_identity_source} ${api_set_context} ${tr_audit_trigger} diff --git a/database/src/migrations/release.0.7/biohub_admin.0.3.sql b/database/src/migrations/release.0.7/biohub_admin.0.3.sql deleted file mode 100644 index d07e810497..0000000000 --- a/database/src/migrations/release.0.7/biohub_admin.0.3.sql +++ /dev/null @@ -1,41 +0,0 @@ --- --- ER/Studio Data Architect SQL Code Generation --- Project : BioHub.DM1 --- --- Date Created : Thursday, December 31, 2020 11:55:28 --- Target DBMS : PostgreSQL 10.x-12.x --- - --- --- TABLE: audit_log --- - -CREATE TABLE audit_log( - id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), - system_user_id integer NOT NULL, - create_at timestamp(6) DEFAULT now() NOT NULL, - table_name varchar(200) NOT NULL, - operation varchar(20) NOT NULL, - before_value json, - after_value json, - CONSTRAINT pk103_1_1 PRIMARY KEY (id) -) -; - - - -COMMENT ON COLUMN audit_log.id IS 'System generated surrogate primary key identifier.' -; -COMMENT ON COLUMN audit_log.system_user_id IS 'The system user id affecting the data change.' -; -COMMENT ON COLUMN audit_log.table_name IS 'The table name of the data record.' -; -COMMENT ON COLUMN audit_log.operation IS 'The operation that affected the data change (ie. INSERT, UPDATE, DELETE, TRUNCATE).' -; -COMMENT ON COLUMN audit_log.before_value IS 'The JSON representation of the before value of the record.' -; -COMMENT ON COLUMN audit_log.after_value IS 'The JSON representation of the after value of the record.' -; -COMMENT ON TABLE audit_log IS 'Holds record level audit log data for the entire database.' -; - diff --git a/database/src/migrations/release.0.7/api_get_context_user_id.sql b/database/src/migrations/release.0.8/api_get_context_user_id.sql similarity index 100% rename from database/src/migrations/release.0.7/api_get_context_user_id.sql rename to database/src/migrations/release.0.8/api_get_context_user_id.sql diff --git a/database/src/migrations/release.0.7/api_set_context.sql b/database/src/migrations/release.0.8/api_set_context.sql similarity index 100% rename from database/src/migrations/release.0.7/api_set_context.sql rename to database/src/migrations/release.0.8/api_set_context.sql diff --git a/database/src/migrations/release.0.7/biohub.0.7.sql b/database/src/migrations/release.0.8/biohub.sql similarity index 88% rename from database/src/migrations/release.0.7/biohub.0.7.sql rename to database/src/migrations/release.0.8/biohub.sql index 4d4cfa6eee..9d4c922f47 100644 --- a/database/src/migrations/release.0.7/biohub.0.7.sql +++ b/database/src/migrations/release.0.8/biohub.sql @@ -2,7 +2,7 @@ -- ER/Studio Data Architect SQL Code Generation -- Project : BioHub.DM1 -- --- Date Created : Wednesday, March 10, 2021 16:57:57 +-- Date Created : Friday, March 19, 2021 13:37:09 -- Target DBMS : PostgreSQL 10.x-12.x -- @@ -397,7 +397,7 @@ COMMENT ON TABLE iucn_conservation_action_level_1_classification IS 'List of IUC CREATE TABLE iucn_conservation_action_level_2_subclassification( id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), - iucn_id integer NOT NULL, + iucn1_id integer NOT NULL, name varchar(300), record_end_date date, record_effective_date date NOT NULL, @@ -415,7 +415,7 @@ CREATE TABLE iucn_conservation_action_level_2_subclassification( COMMENT ON COLUMN iucn_conservation_action_level_2_subclassification.id IS 'System generated surrogate primary key identifier.' ; -COMMENT ON COLUMN iucn_conservation_action_level_2_subclassification.iucn_id IS 'System generated surrogate primary key identifier.' +COMMENT ON COLUMN iucn_conservation_action_level_2_subclassification.iucn1_id IS 'System generated surrogate primary key identifier.' ; COMMENT ON COLUMN iucn_conservation_action_level_2_subclassification.name IS 'The name of the record.' ; @@ -444,7 +444,7 @@ COMMENT ON TABLE iucn_conservation_action_level_2_subclassification IS 'List of CREATE TABLE iucn_conservation_action_level_3_subclassification( id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), - iucn1_id integer NOT NULL, + iucn2_id integer NOT NULL, name varchar(300), record_end_date date, record_effective_date date NOT NULL, @@ -462,7 +462,7 @@ CREATE TABLE iucn_conservation_action_level_3_subclassification( COMMENT ON COLUMN iucn_conservation_action_level_3_subclassification.id IS 'System generated surrogate primary key identifier.' ; -COMMENT ON COLUMN iucn_conservation_action_level_3_subclassification.iucn1_id IS 'System generated surrogate primary key identifier.' +COMMENT ON COLUMN iucn_conservation_action_level_3_subclassification.iucn2_id IS 'System generated surrogate primary key identifier.' ; COMMENT ON COLUMN iucn_conservation_action_level_3_subclassification.name IS 'The name of the IUCN action classification sublevel 2. ' @@ -698,6 +698,50 @@ COMMENT ON COLUMN project_activity.update_user IS 'The id of the user who update COMMENT ON COLUMN project_activity.revision_count IS 'Revision count used for concurrency control.' ; +-- +-- TABLE: project_attachment +-- + +CREATE TABLE project_attachment( + id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + p_id integer NOT NULL, + file_name varchar(300), + title varchar(300), + description varchar(250), + create_date timestamp(6) DEFAULT now() NOT NULL, + create_user integer NOT NULL, + update_date timestamp(6), + update_user integer, + revision_count integer DEFAULT 0 NOT NULL, + CONSTRAINT "PK141" PRIMARY KEY (id) +) +; + + + +COMMENT ON COLUMN project_attachment.id IS 'System generated surrogate primary key identifier.' +; +COMMENT ON COLUMN project_attachment.p_id IS 'System generated surrogate primary key identifier.' +; +COMMENT ON COLUMN project_attachment.file_name IS 'The name of the file attachment.' +; +COMMENT ON COLUMN project_attachment.title IS 'The title of the file.' +; +COMMENT ON COLUMN project_attachment.description IS 'The description of the record.' +; +COMMENT ON COLUMN project_attachment.create_date IS 'The datetime the record was created.' +; +COMMENT ON COLUMN project_attachment.create_user IS 'The id of the user who created the record as identified in the system user table.' +; +COMMENT ON COLUMN project_attachment.update_date IS 'The datetime the record was updated.' +; +COMMENT ON COLUMN project_attachment.update_user IS 'The id of the user who updated the record as identified in the system user table.' +; +COMMENT ON COLUMN project_attachment.revision_count IS 'Revision count used for concurrency control.' +; +COMMENT ON TABLE project_attachment IS 'A list of project attachments.' +; + -- -- TABLE: project_climate_initiative -- @@ -821,13 +865,13 @@ COMMENT ON TABLE project_funding_source IS 'Project funding source details.' ; -- --- TABLE: project_iucn_action_classificaton +-- TABLE: project_iucn_action_classification -- -CREATE TABLE project_iucn_action_classificaton( +CREATE TABLE project_iucn_action_classification( id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), - iucn2_id integer NOT NULL, p_id integer NOT NULL, + iucn3_id integer NOT NULL, create_date timestamp(6) DEFAULT now() NOT NULL, create_user integer NOT NULL, update_date timestamp(6), @@ -839,23 +883,23 @@ CREATE TABLE project_iucn_action_classificaton( -COMMENT ON COLUMN project_iucn_action_classificaton.id IS 'System generated surrogate primary key identifier.' +COMMENT ON COLUMN project_iucn_action_classification.id IS 'System generated surrogate primary key identifier.' ; -COMMENT ON COLUMN project_iucn_action_classificaton.iucn2_id IS 'System generated surrogate primary key identifier.' +COMMENT ON COLUMN project_iucn_action_classification.p_id IS 'System generated surrogate primary key identifier.' ; -COMMENT ON COLUMN project_iucn_action_classificaton.p_id IS 'System generated surrogate primary key identifier.' +COMMENT ON COLUMN project_iucn_action_classification.iucn3_id IS 'System generated surrogate primary key identifier.' ; -COMMENT ON COLUMN project_iucn_action_classificaton.create_date IS 'The datetime the record was created.' +COMMENT ON COLUMN project_iucn_action_classification.create_date IS 'The datetime the record was created.' ; -COMMENT ON COLUMN project_iucn_action_classificaton.create_user IS 'The id of the user who created the record as identified in the system user table.' +COMMENT ON COLUMN project_iucn_action_classification.create_user IS 'The id of the user who created the record as identified in the system user table.' ; -COMMENT ON COLUMN project_iucn_action_classificaton.update_date IS 'The datetime the record was updated.' +COMMENT ON COLUMN project_iucn_action_classification.update_date IS 'The datetime the record was updated.' ; -COMMENT ON COLUMN project_iucn_action_classificaton.update_user IS 'The id of the user who updated the record as identified in the system user table.' +COMMENT ON COLUMN project_iucn_action_classification.update_user IS 'The id of the user who updated the record as identified in the system user table.' ; -COMMENT ON COLUMN project_iucn_action_classificaton.revision_count IS 'Revision count used for concurrency control.' +COMMENT ON COLUMN project_iucn_action_classification.revision_count IS 'Revision count used for concurrency control.' ; -COMMENT ON TABLE project_iucn_action_classificaton IS 'Project IUCN classifications.' +COMMENT ON TABLE project_iucn_action_classification IS 'Project IUCN classifications.' ; -- @@ -1144,6 +1188,50 @@ COMMENT ON COLUMN stakeholder_partnership.revision_count IS 'Revision count used COMMENT ON TABLE stakeholder_partnership IS 'Stakeholder partnerships associated with the project.' ; +-- +-- TABLE: system_constant +-- + +CREATE TABLE system_constant( + id integer GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + constant_name varchar(50) NOT NULL, + character_value varchar(300), + numeric_value numeric(10, 0), + description varchar(250), + create_date timestamp(6) DEFAULT now() NOT NULL, + create_user integer NOT NULL, + update_date timestamp(6), + update_user integer, + revision_count integer DEFAULT 0 NOT NULL, + CONSTRAINT "PK142" PRIMARY KEY (id) +) +; + + + +COMMENT ON COLUMN system_constant.id IS 'System generated surrogate primary key identifier.' +; +COMMENT ON COLUMN system_constant.constant_name IS 'The lookup name of the constant.' +; +COMMENT ON COLUMN system_constant.character_value IS 'The string value of the constant.' +; +COMMENT ON COLUMN system_constant.numeric_value IS 'The numeric value of the constant.' +; +COMMENT ON COLUMN system_constant.description IS 'The description of the record.' +; +COMMENT ON COLUMN system_constant.create_date IS 'The datetime the record was created.' +; +COMMENT ON COLUMN system_constant.create_user IS 'The id of the user who created the record as identified in the system user table.' +; +COMMENT ON COLUMN system_constant.update_date IS 'The datetime the record was updated.' +; +COMMENT ON COLUMN system_constant.update_user IS 'The id of the user who updated the record as identified in the system user table.' +; +COMMENT ON COLUMN system_constant.revision_count IS 'Revision count used for concurrency control.' +; +COMMENT ON TABLE system_constant IS 'A list of system constants necessary for system functionality.' +; + -- -- TABLE: system_role -- @@ -1381,28 +1469,28 @@ CREATE INDEX "Ref7345" ON investment_action_category(fs_id) CREATE UNIQUE INDEX iucn_nuk1 ON iucn_conservation_action_level_1_classification(name, (record_end_date is NULL)) where record_end_date is null ; -- --- INDEX: iac1_nuk1 +-- INDEX: iucn2_nuk1 -- -CREATE UNIQUE INDEX iac1_nuk1 ON iucn_conservation_action_level_2_subclassification(iucn_id, name, (record_end_date is NULL)) where record_end_date is null +CREATE UNIQUE INDEX iucn2_nuk1 ON iucn_conservation_action_level_2_subclassification(name, record_end_date, iucn1_id) ; -- --- INDEX: "Ref13764" +-- INDEX: "Ref13773" -- -CREATE INDEX "Ref13764" ON iucn_conservation_action_level_2_subclassification(iucn_id) +CREATE INDEX "Ref13773" ON iucn_conservation_action_level_2_subclassification(iucn1_id) ; -- --- INDEX: iac2_nuk1 +-- INDEX: iucn3_nuk1 -- -CREATE UNIQUE INDEX iac2_nuk1 ON iucn_conservation_action_level_3_subclassification(iucn1_id, name, (record_end_date is NULL)) where record_end_date is null +CREATE UNIQUE INDEX iucn3_nuk1 ON iucn_conservation_action_level_3_subclassification(name, iucn2_id, (record_end_date is NULL)) where record_end_date is null ; -- --- INDEX: "Ref13965" +-- INDEX: "Ref13974" -- -CREATE INDEX "Ref13965" ON iucn_conservation_action_level_3_subclassification(iucn1_id) +CREATE INDEX "Ref13974" ON iucn_conservation_action_level_3_subclassification(iucn2_id) ; -- -- INDEX: mat_nuk1 @@ -1441,6 +1529,18 @@ CREATE INDEX "Ref4556" ON project_activity(p_id) CREATE INDEX "Ref13658" ON project_activity(a_id) ; -- +-- INDEX: pat_uk1 +-- + +CREATE UNIQUE INDEX pat_uk1 ON project_attachment(p_id, file_name) +; +-- +-- INDEX: "Ref4568" +-- + +CREATE INDEX "Ref4568" ON project_attachment(p_id) +; +-- -- INDEX: pci_uk1 -- @@ -1495,22 +1595,22 @@ CREATE INDEX "Ref4520" ON project_funding_source(p_id) CREATE INDEX "Ref8351" ON project_funding_source(iac_id) ; -- --- INDEX: piac_uk1 +-- INDEX: piucn_uk1 -- -CREATE UNIQUE INDEX piac_uk1 ON project_iucn_action_classificaton(iucn2_id, p_id) +CREATE UNIQUE INDEX piucn_uk1 ON project_iucn_action_classification(p_id, iucn3_id) ; -- --- INDEX: "Ref14066" +-- INDEX: "Ref4567" -- -CREATE INDEX "Ref14066" ON project_iucn_action_classificaton(iucn2_id) +CREATE INDEX "Ref4567" ON project_iucn_action_classification(p_id) ; -- --- INDEX: "Ref4567" +-- INDEX: "Ref14075" -- -CREATE INDEX "Ref4567" ON project_iucn_action_classificaton(p_id) +CREATE INDEX "Ref14075" ON project_iucn_action_classification(iucn3_id) ; -- -- INDEX: pma_uk1 @@ -1603,6 +1703,12 @@ CREATE UNIQUE INDEX sp_uk1 ON stakeholder_partnership(name, p_id) CREATE INDEX "Ref4539" ON stakeholder_partnership(p_id) ; -- +-- INDEX: sc_uk1 +-- + +CREATE UNIQUE INDEX sc_uk1 ON system_constant(constant_name) +; +-- -- INDEX: sr_nuk1 -- @@ -1678,8 +1784,8 @@ ALTER TABLE investment_action_category ADD CONSTRAINT "Reffunding_source45" -- TABLE: iucn_conservation_action_level_2_subclassification -- -ALTER TABLE iucn_conservation_action_level_2_subclassification ADD CONSTRAINT "Refiucn_conservation_action_level_1_classification64" - FOREIGN KEY (iucn_id) +ALTER TABLE iucn_conservation_action_level_2_subclassification ADD CONSTRAINT "Refiucn_conservation_action_level_1_classification73" + FOREIGN KEY (iucn1_id) REFERENCES iucn_conservation_action_level_1_classification(id) ; @@ -1688,8 +1794,8 @@ ALTER TABLE iucn_conservation_action_level_2_subclassification ADD CONSTRAINT "R -- TABLE: iucn_conservation_action_level_3_subclassification -- -ALTER TABLE iucn_conservation_action_level_3_subclassification ADD CONSTRAINT "Refiucn_conservation_action_level_2_subclassification65" - FOREIGN KEY (iucn1_id) +ALTER TABLE iucn_conservation_action_level_3_subclassification ADD CONSTRAINT "Refiucn_conservation_action_level_2_subclassification74" + FOREIGN KEY (iucn2_id) REFERENCES iucn_conservation_action_level_2_subclassification(id) ; @@ -1719,6 +1825,16 @@ ALTER TABLE project_activity ADD CONSTRAINT "Refactivity58" ; +-- +-- TABLE: project_attachment +-- + +ALTER TABLE project_attachment ADD CONSTRAINT "Refproject68" + FOREIGN KEY (p_id) + REFERENCES project(id) +; + + -- -- TABLE: project_climate_initiative -- @@ -1765,19 +1881,19 @@ ALTER TABLE project_funding_source ADD CONSTRAINT "Refinvestment_action_category -- --- TABLE: project_iucn_action_classificaton +-- TABLE: project_iucn_action_classification -- -ALTER TABLE project_iucn_action_classificaton ADD CONSTRAINT "Refiucn_conservation_action_level_3_subclassification66" - FOREIGN KEY (iucn2_id) - REFERENCES iucn_conservation_action_level_3_subclassification(id) -; - -ALTER TABLE project_iucn_action_classificaton ADD CONSTRAINT "Refproject67" +ALTER TABLE project_iucn_action_classification ADD CONSTRAINT "Refproject67" FOREIGN KEY (p_id) REFERENCES project(id) ; +ALTER TABLE project_iucn_action_classification ADD CONSTRAINT "Refiucn_conservation_action_level_3_subclassification75" + FOREIGN KEY (iucn3_id) + REFERENCES iucn_conservation_action_level_3_subclassification(id) +; + -- -- TABLE: project_management_actions diff --git a/database/src/migrations/release.0.7/create_spatial_extensions.psql b/database/src/migrations/release.0.8/create_spatial_extensions.psql similarity index 86% rename from database/src/migrations/release.0.7/create_spatial_extensions.psql rename to database/src/migrations/release.0.8/create_spatial_extensions.psql index 5f6fd796b7..3e0e1843a0 100644 --- a/database/src/migrations/release.0.7/create_spatial_extensions.psql +++ b/database/src/migrations/release.0.8/create_spatial_extensions.psql @@ -5,4 +5,4 @@ CREATE EXTENSION IF NOT EXISTS postgis_topology CASCADE; CREATE EXTENSION IF NOT EXISTS postgis_sfcgal CASCADE; CREATE EXTENSION IF NOT EXISTS pgRouting CASCADE; CREATE EXTENSION IF NOT EXISTS fuzzystrmatch CASCADE; -CREATE EXTENSION IF NOT EXISTS pgcrypto CASCADE; +CREATE EXTENSION IF NOT EXISTS pgcrypto CASCADE; \ No newline at end of file diff --git a/database/src/migrations/release.0.8/db_setup_up.sql b/database/src/migrations/release.0.8/db_setup_up.sql new file mode 100644 index 0000000000..c3db2e58f6 --- /dev/null +++ b/database/src/migrations/release.0.8/db_setup_up.sql @@ -0,0 +1,53 @@ +-- db_setup_up.sql +-- TODO: lock down public but allow access to postgis installed there +--REVOKE ALL PRIVILEGES ON SCHEMA public FROM PUBLIC; + +-- set up spatial extensions +\i create_spatial_extensions.psql + +-- set up project management schema +create schema if not exists biohub; +set search_path = biohub, public; +\i biohub.sql +\i populate_user_identity_source.sql +\i api_set_context.sql +\i tr_audit_trigger.sql +\i project_audit_triggers.sql +\i api_get_context_user_id.sql +\i tr_journal_trigger.sql +\i project_journal_triggers.sql +\i tr_project_funding_source.sql + +-- populate look up tables +set search_path = biohub; +\i populate_first_nations.sql +\i populate_climate_change_initiatives.sql +\i populate_management_action_type.sql +\i populate_funding_source.sql +\i populate_investment_action_category.sql +\i populate_project_type.sql +\i populate_activity.sql +\i populate_icun_classifications.sql + +-- postgis reader role +--create role postgis_reader inherit; +--grant select on public.geometry_columns to postgis_reader; +--grant select on public.geography_columns to postgis_reader; +--grant select on public.spatial_ref_sys to postgis_reader; + +-- setup biohub api schema +create schema if not exists biohub_dapi_v1; +set search_path = biohub_dapi_v1; +\i project_dapi_views.sql + +-- setup api user +create user biohub_api password 'flatpass'; +grant usage on schema biohub_dapi_v1 to biohub_api; +grant usage on schema biohub to biohub_api; +grant all on all tables in schema biohub_dapi_v1 to biohub_api; +alter DEFAULT PRIVILEGES in SCHEMA biohub_dapi_v1 grant ALL on tables to biohub_api; +--grant postgis_reader to biohub_api; +alter role biohub_api set search_path to biohub_dapi_v1, biohub, public, topology; + +set search_path = biohub; +grant execute on function api_set_context(idir_user_id system_user.user_identifier%type, bceid_user_id system_user.user_identifier%type) to biohub_api; diff --git a/database/src/migrations/release.0.7/populate_activity.sql b/database/src/migrations/release.0.8/populate_activity.sql similarity index 96% rename from database/src/migrations/release.0.7/populate_activity.sql rename to database/src/migrations/release.0.8/populate_activity.sql index d6fef7caf6..c8a31a3a06 100644 --- a/database/src/migrations/release.0.7/populate_activity.sql +++ b/database/src/migrations/release.0.8/populate_activity.sql @@ -5,4 +5,4 @@ insert into activity (name, record_effective_date) values ('Habitat Restoration insert into activity (name, record_effective_date) values ('Habitat Research', now()); insert into activity (name, record_effective_date) values ('Habitat Protection', now()); insert into activity (name, record_effective_date) values ('Salvage', now()); -insert into activity (name, record_effective_date) values ('Research', now()); +insert into activity (name, record_effective_date) values ('Research', now()); \ No newline at end of file diff --git a/database/src/migrations/release.0.7/populate_climate_change_initiatives.sql b/database/src/migrations/release.0.8/populate_climate_change_initiatives.sql similarity index 88% rename from database/src/migrations/release.0.7/populate_climate_change_initiatives.sql rename to database/src/migrations/release.0.8/populate_climate_change_initiatives.sql index 779b55b122..6830bf7a74 100644 --- a/database/src/migrations/release.0.7/populate_climate_change_initiatives.sql +++ b/database/src/migrations/release.0.8/populate_climate_change_initiatives.sql @@ -1,4 +1,4 @@ -- populate_climate_change_initiatives.sql insert into climate_change_initiative (name, record_effective_date) VALUES ('Adaptation', now()); insert into climate_change_initiative (name, record_effective_date) VALUES ('Monitoring', now()); -insert into climate_change_initiative (name, record_effective_date) VALUES ('Mitigation', now()); +insert into climate_change_initiative (name, record_effective_date) VALUES ('Mitigation', now()); \ No newline at end of file diff --git a/database/src/migrations/release.0.7/populate_first_nations.sql b/database/src/migrations/release.0.8/populate_first_nations.sql similarity index 100% rename from database/src/migrations/release.0.7/populate_first_nations.sql rename to database/src/migrations/release.0.8/populate_first_nations.sql diff --git a/database/src/migrations/release.0.7/populate_funding_source.sql b/database/src/migrations/release.0.8/populate_funding_source.sql similarity index 100% rename from database/src/migrations/release.0.7/populate_funding_source.sql rename to database/src/migrations/release.0.8/populate_funding_source.sql diff --git a/database/src/migrations/release.0.7/populate_icun_classifications.sql b/database/src/migrations/release.0.8/populate_icun_classifications.sql similarity index 55% rename from database/src/migrations/release.0.7/populate_icun_classifications.sql rename to database/src/migrations/release.0.8/populate_icun_classifications.sql index 7e142b3f07..0b95480263 100644 --- a/database/src/migrations/release.0.7/populate_icun_classifications.sql +++ b/database/src/migrations/release.0.8/populate_icun_classifications.sql @@ -9,163 +9,163 @@ declare begin -- 1.0.0 insert into iucn_conservation_action_level_1_classification(record_effective_date, name) values (now(), 'Land / Water Management') returning id into __id; - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Site/Ecosystem Stewardship (Habitat improvement/maintenance)','Enhancing or maintaining the quality of existing habitat by mitigating stresses to sites and or other ecosystem targets. Theses actions do not result in the additon of hectares of usable habitat but rather the retention of habitat in it''s current or an improvedstate. These actions may need to be repeated over subsequent years.') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Removing invasives, pests or weeds ',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Planting vegetation to improve habitat',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Managing, controlling, or changing hydrological regimes',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Mimicking natural disturbance regimes (flooding, fire) ',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Mechanical actions (e.g. mowing, thinning)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Chemical actions (e.g. liming ponds)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Biological control (e.g. oil eating microbes)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Sensory control (e.g. predator urine, noise deterrents)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Separation / border actions (e.g fencing, gating caves)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Visitor management (e.g. sinage, trail closures/re-routing)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Implementation of best management practices or land use guidelines',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Debris removal (garbage, natural debris, contaminants)',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Ecosystem & Natural Process (Re)Creation (Habitat restoration)','Building or restoring key ecosystem structural components, abiotic functions & processes, biotic functions & processes to create or replace habitat which was missing, or in such poor condition that it was considered unusable. These actions add hectares of new habitat, and differs from actions considered site/ecosystem stewardship actions based on the initial state of the habitat.') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Removing invasives, pests or weeds',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Planting vegetation to create habitat',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Managing, controlling, or changing hydrological regimes',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Mimicing natural disturbance regimes (e.g. fire)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Mechanical actions (e.g. mowing, thinning)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Chemical actions (e.g. liming ponds)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Biological control (e.g. oil eating microbes)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Breeching embankments to restore wetlands (levees, dikes, dams)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Removing roads, trails or other linear disturbances',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Site/Ecosystem Stewardship (Habitat improvement/maintenance)','Enhancing or maintaining the quality of existing habitat by mitigating stresses to sites and or other ecosystem targets. Theses actions do not result in the additon of hectares of usable habitat but rather the retention of habitat in it''s current or an improvedstate. These actions may need to be repeated over subsequent years.') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Removing invasives, pests or weeds ',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Planting vegetation to improve habitat',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Managing, controlling, or changing hydrological regimes',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Mimicking natural disturbance regimes (flooding, fire) ',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Mechanical actions (e.g. mowing, thinning)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Chemical actions (e.g. liming ponds)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Biological control (e.g. oil eating microbes)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Sensory control (e.g. predator urine, noise deterrents)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Separation / border actions (e.g fencing, gating caves)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Visitor management (e.g. sinage, trail closures/re-routing)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Implementation of best management practices or land use guidelines',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Debris removal (garbage, natural debris, contaminants)',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Ecosystem & Natural Process (Re)Creation (Habitat restoration)','Building or restoring key ecosystem structural components, abiotic functions & processes, biotic functions & processes to create or replace habitat which was missing, or in such poor condition that it was considered unusable. These actions add hectares of new habitat, and differs from actions considered site/ecosystem stewardship actions based on the initial state of the habitat.') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Removing invasives, pests or weeds',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Planting vegetation to create habitat',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Managing, controlling, or changing hydrological regimes',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Mimicing natural disturbance regimes (e.g. fire)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Mechanical actions (e.g. mowing, thinning)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Chemical actions (e.g. liming ponds)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Biological control (e.g. oil eating microbes)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Breeching embankments to restore wetlands (levees, dikes, dams)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Removing roads, trails or other linear disturbances',''); -- 2.0.0 insert into iucn_conservation_action_level_1_classification(record_effective_date, name) values (now(), 'Species Management') returning id into __id; - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Species Stewardship','Enhancing viability of, or mitigating stresses to specific species or taxonomic groupings through management actions within their current range (in-situ).') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Species-structure creation',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Nutrient / water management',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Reproduction management (e.g. manual pollination, maternal penning)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Disease / injury management',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Movement / migration management ',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Interspecific interaction management (e.g predator/competitor removal, predator exclusion fences)',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Species Re-Introduction & Translocation','Transferring species or genetic material to places where they formerly occurred, to suitable future habitat, or benign introductions of species to an ecosystem.') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Reintroduction of species',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Reinforcement of species ',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Assisted colonisation',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Ex-Situ Conservation','Protecting specific species in artificial settings with the aim of ultimately restoring them to their natural settings') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Support within the life of an individual (e.g. offsite rehabilitation of injured animals)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Support / captive breeding over generations',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Gene banking ',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Species Stewardship','Enhancing viability of, or mitigating stresses to specific species or taxonomic groupings through management actions within their current range (in-situ).') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Species-structure creation',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Nutrient / water management',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Reproduction management (e.g. manual pollination, maternal penning)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Disease / injury management',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Movement / migration management ',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Interspecific interaction management (e.g predator/competitor removal, predator exclusion fences)',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Species Re-Introduction & Translocation','Transferring species or genetic material to places where they formerly occurred, to suitable future habitat, or benign introductions of species to an ecosystem.') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Reintroduction of species',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Reinforcement of species ',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Assisted colonisation',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Ex-Situ Conservation','Protecting specific species in artificial settings with the aim of ultimately restoring them to their natural settings') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Support within the life of an individual (e.g. offsite rehabilitation of injured animals)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Support / captive breeding over generations',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Gene banking ',''); -- 3.0.0 insert into iucn_conservation_action_level_1_classification(record_effective_date, name) values (now(), 'Awareness Raising') returning id into __id; - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Outreach & Communications','Promoting desired awareness and/or emotions and subsequent behavior change by providing information to target audiences through appropriate channels') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Reported and social media',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Ads & marketing',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Art',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Person-to-person engagement',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Outreach & Communications','Promoting desired awareness and/or emotions and subsequent behavior change by providing information to target audiences through appropriate channels') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Reported and social media',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Ads & marketing',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Art',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Person-to-person engagement',''); -- 4.0.0 insert into iucn_conservation_action_level_1_classification(record_effective_date, name) values (now(), 'Law Enforcement & Prosecution') returning id into __id; - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Illegal acts detection','Detecting and/or deterring violations of existing laws and policies') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Surveillance/ Patrolling',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Carrying out investigations',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Arrest & interdiction',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Criminal Prosecution & Conviction','Ensuring appropriate application of sanctions for violations of existing laws and policies') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Prosecuting alleged crimes',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Trying alleged crimes',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Punishing proven crimes (prisons, fine collection, rehabilitation)"',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Non-Criminal Legal Action','Threatening or bringing non-criminal legal action to get individuals, organizations, agencies or firms to change or deter undesired behaviors or compel conservation action') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Civil law suits',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Agency enforcement',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Agency or judicial review"',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Illegal acts detection','Detecting and/or deterring violations of existing laws and policies') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Surveillance/ Patrolling',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Carrying out investigations',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Arrest & interdiction',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Criminal Prosecution & Conviction','Ensuring appropriate application of sanctions for violations of existing laws and policies') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Prosecuting alleged crimes',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Trying alleged crimes',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Punishing proven crimes (prisons, fine collection, rehabilitation)"',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Non-Criminal Legal Action','Threatening or bringing non-criminal legal action to get individuals, organizations, agencies or firms to change or deter undesired behaviors or compel conservation action') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Civil law suits',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Agency enforcement',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Agency or judicial review"',''); -- 5.0.0 insert into iucn_conservation_action_level_1_classification(record_effective_date, name) values (now(), 'Livelihood, Economic & Moral Incentives') returning id into __id; - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Better Products & Management Practices','Developing, promoting and/or providing more environmentally-friendly products or practices') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Developing better products & practices',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Promoting better products & practices',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Removing barriers to adoption of better products or practices',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Market-Based Incentives','Using market mechanisms to change behaviors and attitudes') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Green certification of products or services',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Environmental markets (eg CO2 emissions, water)',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Direct Economic Incentives','Using direct or indirect payments or ascribing economic value to change behaviors and attitudes') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Direct payments or subsidies for desired behaviors',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Taxes on undesired behaviors',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Valuation of ecological services to leverage conservation ',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Monetary awards & prizes ',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Non-Monetary Values','Using intangible and moral values to change behaviors and attitudes') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Health & social service benefits',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Security benefits',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Spiritual / moral / cultural benefits',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Better Products & Management Practices','Developing, promoting and/or providing more environmentally-friendly products or practices') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Developing better products & practices',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Promoting better products & practices',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Removing barriers to adoption of better products or practices',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Market-Based Incentives','Using market mechanisms to change behaviors and attitudes') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Green certification of products or services',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Environmental markets (eg CO2 emissions, water)',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Direct Economic Incentives','Using direct or indirect payments or ascribing economic value to change behaviors and attitudes') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Direct payments or subsidies for desired behaviors',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Taxes on undesired behaviors',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Valuation of ecological services to leverage conservation ',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Monetary awards & prizes ',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Non-Monetary Values','Using intangible and moral values to change behaviors and attitudes') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Health & social service benefits',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Security benefits',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Spiritual / moral / cultural benefits',''); -- 6.0.0 insert into iucn_conservation_action_level_1_classification(record_effective_date, name) values (now(), 'Conservation Designation & Planning') returning id into __id; - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Protected Area Designation &/or Acquisition','Securing habitat to legally, formally establish or expand public or private parks, reserves, and other protected areas roughly equivalent to IUCN Categories I-IV') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Government protected area',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Indigenous protected and conserved area',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Privately owned conservation lands',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Easements & Resource Rights','Legally or formally securing some specific aspect of the natural resources on public or private lands') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Conservation Encumbrance (lease/easements/covenants/servitude)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Purchase of specific resource rights',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Conservation agreements',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Certificates of possession',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Crown land designations',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Land/Water use zoning and Other Conserved Area Designation','Designating conservation areas outside of IUCN Categories I-IV') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Conservation area designation (other than protected areas)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Bylaws',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Land/Water Use Zoning',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Conservation Planning','Planning for management of sites, species, or thematic conservation projects') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Area based plan (habitat or multi-species focused)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Species specific plan',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Planning for thematic projects or programs',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Logistics plan',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Protected Area Designation &/or Acquisition','Securing habitat to legally, formally establish or expand public or private parks, reserves, and other protected areas roughly equivalent to IUCN Categories I-IV') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Government protected area',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Indigenous protected and conserved area',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Privately owned conservation lands',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Easements & Resource Rights','Legally or formally securing some specific aspect of the natural resources on public or private lands') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Conservation Encumbrance (lease/easements/covenants/servitude)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Purchase of specific resource rights',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Conservation agreements',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Certificates of possession',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Crown land designations',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Land/Water use zoning and Other Conserved Area Designation','Designating conservation areas outside of IUCN Categories I-IV') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Conservation area designation (other than protected areas)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Bylaws',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Land/Water Use Zoning',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Conservation Planning','Planning for management of sites, species, or thematic conservation projects') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Area based plan (habitat or multi-species focused)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Species specific plan',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Planning for thematic projects or programs',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Logistics plan',''); -- 7.0.0 insert into iucn_conservation_action_level_1_classification(record_effective_date, name) values (now(), 'Legal & Policy Frameworks') returning id into __id; - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Laws, Regulations & Codes','Creating or amending laws, regulations and codes at all levels') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'International law, conventions & treaties',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'National law or regulations',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'State/provincial law or regulations',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Municipal law or regulations',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Tribal law & formal customs',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Private sector/civil society codes',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Cross-sectoral',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Policies & Guidelines','Creating or amending policies and guidelines at all levels') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'International policies',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'National polices',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'State/provincial policies',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Municipal policies',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Tribal policies',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Private sector/civil society policies',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Cross-sectoral',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Laws, Regulations & Codes','Creating or amending laws, regulations and codes at all levels') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'International law, conventions & treaties',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'National law or regulations',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'State/provincial law or regulations',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Municipal law or regulations',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Tribal law & formal customs',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Private sector/civil society codes',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Cross-sectoral',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Policies & Guidelines','Creating or amending policies and guidelines at all levels') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'International policies',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'National polices',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'State/provincial policies',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Municipal policies',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Tribal policies',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Private sector/civil society policies',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Cross-sectoral',''); -- 8.0.0 insert into iucn_conservation_action_level_1_classification(record_effective_date, name) values (now(), 'Research & Monitoring') returning id into __id; - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Basic Research & Status Monitoring','Collecting, managing and analyzing data; creating information; gathering, managing, analyzing, co-applying knowledges about any conservation-related factors ') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Field Research/Monitoring',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Desktop/Benchtop research and analysis',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Indigenous Knowledge Gathering',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Local Ecological Knowledge Collection',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Public Opinion Research',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Evaluation, Effectiveness Measures & Learning','Assessing, learning, and summarizing the results of learning about the effectiveness of conservation work') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Project level evaluations ',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Cross-project or program comparisons',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Systematic reviews of action effectiveness ',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Results summaries and reports ',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Basic Research & Status Monitoring','Collecting, managing and analyzing data; creating information; gathering, managing, analyzing, co-applying knowledges about any conservation-related factors ') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Field Research/Monitoring',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Desktop/Benchtop research and analysis',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Indigenous Knowledge Gathering',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Local Ecological Knowledge Collection',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Public Opinion Research',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Evaluation, Effectiveness Measures & Learning','Assessing, learning, and summarizing the results of learning about the effectiveness of conservation work') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Project level evaluations ',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Cross-project or program comparisons',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Systematic reviews of action effectiveness ',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Results summaries and reports ',''); -- 9.0.0 insert into iucn_conservation_action_level_1_classification(record_effective_date, name) values (now(), 'Education & Training') returning id into __id; - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Formal Education','Enhancing knowledge and skills of students in a formal degree program') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Primary education',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Secondary education',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'College or university education',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Adult / continuing education',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Training & Individual Capacity Development','Enhancing knowledge, skills and information exchange for practitioners, stakeholders, and other relevant individuals in structured settings outside of degree programs') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Hands-on coaching & technical assistance',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Workshops & professional development training courses',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Developing training materials and programs',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Formal Education','Enhancing knowledge and skills of students in a formal degree program') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Primary education',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Secondary education',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'College or university education',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Adult / continuing education',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Training & Individual Capacity Development','Enhancing knowledge, skills and information exchange for practitioners, stakeholders, and other relevant individuals in structured settings outside of degree programs') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Hands-on coaching & technical assistance',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Workshops & professional development training courses',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Developing training materials and programs',''); -- 10.0.0 insert into iucn_conservation_action_level_1_classification(record_effective_date, name) values (now(), 'Institutional Development') returning id into __id; - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Internal Organizational Management & Administration','Completing the basic work needed to establish and operate conservation organizations') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Project level administration and delivery',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'External Organizational Development & Support','Creating or providing support (financial or non-financial) and capacity building for conservation organizations') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Direct support services (in-kind)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Organizational establishment & incubation (formal establishment of new organizations, groups, initiatives)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Developing / providing organizational services (co-ordinating roles)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Providing financial support for hiring workers/employees ',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Alliance & Partnership Development','Forming, facilitating and maintaining partnerships, alliances, and networks of organizations') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Forming relationships',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Maintaining or strengthening relationships ',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Facilitating consultations/engagement (e.g. providing financial support)',''); - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Knowledge sharing',''); - insert into iucn_conservation_action_level_2_subclassification(iucn_id, record_effective_date, name, description) values (__id, now(), 'Financing Conservation','Raising and providing funds for conservation work ') returning id into __id2; - insert into iucn_conservation_action_level_3_subclassification(iucn1_id, record_effective_date, name, description) values (__id2, now(), 'Securing/raising funds needed to complete consevation actions ',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Internal Organizational Management & Administration','Completing the basic work needed to establish and operate conservation organizations') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Project level administration and delivery',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'External Organizational Development & Support','Creating or providing support (financial or non-financial) and capacity building for conservation organizations') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Direct support services (in-kind)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Organizational establishment & incubation (formal establishment of new organizations, groups, initiatives)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Developing / providing organizational services (co-ordinating roles)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Providing financial support for hiring workers/employees ',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Alliance & Partnership Development','Forming, facilitating and maintaining partnerships, alliances, and networks of organizations') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Forming relationships',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Maintaining or strengthening relationships ',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Facilitating consultations/engagement (e.g. providing financial support)',''); + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Knowledge sharing',''); + insert into iucn_conservation_action_level_2_subclassification(iucn1_id, record_effective_date, name, description) values (__id, now(), 'Financing Conservation','Raising and providing funds for conservation work ') returning id into __id2; + insert into iucn_conservation_action_level_3_subclassification(iucn2_id, record_effective_date, name, description) values (__id2, now(), 'Securing/raising funds needed to complete consevation actions ',''); end $$; \ No newline at end of file diff --git a/database/src/migrations/release.0.7/populate_investment_action_category.sql b/database/src/migrations/release.0.8/populate_investment_action_category.sql similarity index 100% rename from database/src/migrations/release.0.7/populate_investment_action_category.sql rename to database/src/migrations/release.0.8/populate_investment_action_category.sql diff --git a/database/src/migrations/release.0.7/populate_management_action_type.sql b/database/src/migrations/release.0.8/populate_management_action_type.sql similarity index 100% rename from database/src/migrations/release.0.7/populate_management_action_type.sql rename to database/src/migrations/release.0.8/populate_management_action_type.sql diff --git a/database/src/migrations/release.0.7/populate_project_type.sql b/database/src/migrations/release.0.8/populate_project_type.sql similarity index 100% rename from database/src/migrations/release.0.7/populate_project_type.sql rename to database/src/migrations/release.0.8/populate_project_type.sql diff --git a/database/src/migrations/release.0.7/populate_user_identity_source.sql b/database/src/migrations/release.0.8/populate_user_identity_source.sql similarity index 100% rename from database/src/migrations/release.0.7/populate_user_identity_source.sql rename to database/src/migrations/release.0.8/populate_user_identity_source.sql diff --git a/database/src/migrations/release.0.7/project_audit_triggers.sql b/database/src/migrations/release.0.8/project_audit_triggers.sql similarity index 89% rename from database/src/migrations/release.0.7/project_audit_triggers.sql rename to database/src/migrations/release.0.8/project_audit_triggers.sql index d8016d7a3a..aa966e3e7a 100644 --- a/database/src/migrations/release.0.7/project_audit_triggers.sql +++ b/database/src/migrations/release.0.8/project_audit_triggers.sql @@ -5,28 +5,30 @@ drop trigger if exists audit_iucn_conservation_action_level_1_classification on biohub.iucn_conservation_action_level_1_classification; drop trigger if exists audit_focal_species on biohub.focal_species; drop trigger if exists audit_project_activity on biohub.project_activity; + drop trigger if exists audit_no_sample_permit on biohub.no_sample_permit; drop trigger if exists audit_iucn_conservation_action_level_2_subclassification on biohub.iucn_conservation_action_level_2_subclassification; - drop trigger if exists audit_iucn_conservation_action_level_3_subclassification on biohub.iucn_conservation_action_level_3_subclassification; drop trigger if exists audit_project_climate_initiative on biohub.project_climate_initiative; + drop trigger if exists audit_iucn_conservation_action_level_3_subclassification on biohub.iucn_conservation_action_level_3_subclassification; + drop trigger if exists audit_project_attachment on biohub.project_attachment; drop trigger if exists audit_project_first_nation on biohub.project_first_nation; - drop trigger if exists audit_project_funding_source on biohub.project_funding_source; - drop trigger if exists audit_project_iucn_action_classificaton on biohub.project_iucn_action_classificaton; drop trigger if exists audit_management_action_type on biohub.management_action_type; - drop trigger if exists audit_no_sample_permit on biohub.no_sample_permit; + drop trigger if exists audit_project_iucn_action_classification on biohub.project_iucn_action_classification; + drop trigger if exists audit_system_constant on biohub.system_constant; + drop trigger if exists audit_project_type on biohub.project_type; drop trigger if exists audit_project_participation on biohub.project_participation; - drop trigger if exists audit_system_user on biohub.system_user; drop trigger if exists audit_project_role on biohub.project_role; + drop trigger if exists audit_project_permit on biohub.project_permit; drop trigger if exists audit_project_region on biohub.project_region; drop trigger if exists audit_stakeholder_partnership on biohub.stakeholder_partnership; drop trigger if exists audit_system_user_role on biohub.system_user_role; + drop trigger if exists audit_user_identity_source on biohub.user_identity_source; drop trigger if exists audit_system_role on biohub.system_role; drop trigger if exists audit_project on biohub.project; drop trigger if exists audit_ancillary_species on biohub.ancillary_species; drop trigger if exists audit_investment_action_category on biohub.investment_action_category; - drop trigger if exists audit_project_type on biohub.project_type; + drop trigger if exists audit_project_funding_source on biohub.project_funding_source; drop trigger if exists audit_project_management_actions on biohub.project_management_actions; - drop trigger if exists audit_project_permit on biohub.project_permit; - drop trigger if exists audit_user_identity_source on biohub.user_identity_source; + drop trigger if exists audit_system_user on biohub.system_user; create trigger audit_activity before insert or update or delete on biohub.activity for each row execute procedure tr_audit_trigger(); create trigger audit_climate_change_initiative before insert or update or delete on biohub.climate_change_initiative for each row execute procedure tr_audit_trigger(); @@ -35,26 +37,28 @@ create trigger audit_iucn_conservation_action_level_1_classification before insert or update or delete on biohub.iucn_conservation_action_level_1_classification for each row execute procedure tr_audit_trigger(); create trigger audit_focal_species before insert or update or delete on biohub.focal_species for each row execute procedure tr_audit_trigger(); create trigger audit_project_activity before insert or update or delete on biohub.project_activity for each row execute procedure tr_audit_trigger(); + create trigger audit_no_sample_permit before insert or update or delete on biohub.no_sample_permit for each row execute procedure tr_audit_trigger(); create trigger audit_iucn_conservation_action_level_2_subclassification before insert or update or delete on biohub.iucn_conservation_action_level_2_subclassification for each row execute procedure tr_audit_trigger(); - create trigger audit_iucn_conservation_action_level_3_subclassification before insert or update or delete on biohub.iucn_conservation_action_level_3_subclassification for each row execute procedure tr_audit_trigger(); create trigger audit_project_climate_initiative before insert or update or delete on biohub.project_climate_initiative for each row execute procedure tr_audit_trigger(); + create trigger audit_iucn_conservation_action_level_3_subclassification before insert or update or delete on biohub.iucn_conservation_action_level_3_subclassification for each row execute procedure tr_audit_trigger(); + create trigger audit_project_attachment before insert or update or delete on biohub.project_attachment for each row execute procedure tr_audit_trigger(); create trigger audit_project_first_nation before insert or update or delete on biohub.project_first_nation for each row execute procedure tr_audit_trigger(); - create trigger audit_project_funding_source before insert or update or delete on biohub.project_funding_source for each row execute procedure tr_audit_trigger(); - create trigger audit_project_iucn_action_classificaton before insert or update or delete on biohub.project_iucn_action_classificaton for each row execute procedure tr_audit_trigger(); create trigger audit_management_action_type before insert or update or delete on biohub.management_action_type for each row execute procedure tr_audit_trigger(); - create trigger audit_no_sample_permit before insert or update or delete on biohub.no_sample_permit for each row execute procedure tr_audit_trigger(); + create trigger audit_project_iucn_action_classification before insert or update or delete on biohub.project_iucn_action_classification for each row execute procedure tr_audit_trigger(); + create trigger audit_system_constant before insert or update or delete on biohub.system_constant for each row execute procedure tr_audit_trigger(); + create trigger audit_project_type before insert or update or delete on biohub.project_type for each row execute procedure tr_audit_trigger(); create trigger audit_project_participation before insert or update or delete on biohub.project_participation for each row execute procedure tr_audit_trigger(); - create trigger audit_system_user before insert or update or delete on biohub.system_user for each row execute procedure tr_audit_trigger(); create trigger audit_project_role before insert or update or delete on biohub.project_role for each row execute procedure tr_audit_trigger(); + create trigger audit_project_permit before insert or update or delete on biohub.project_permit for each row execute procedure tr_audit_trigger(); create trigger audit_project_region before insert or update or delete on biohub.project_region for each row execute procedure tr_audit_trigger(); create trigger audit_stakeholder_partnership before insert or update or delete on biohub.stakeholder_partnership for each row execute procedure tr_audit_trigger(); create trigger audit_system_user_role before insert or update or delete on biohub.system_user_role for each row execute procedure tr_audit_trigger(); + create trigger audit_user_identity_source before insert or update or delete on biohub.user_identity_source for each row execute procedure tr_audit_trigger(); create trigger audit_system_role before insert or update or delete on biohub.system_role for each row execute procedure tr_audit_trigger(); create trigger audit_project before insert or update or delete on biohub.project for each row execute procedure tr_audit_trigger(); create trigger audit_ancillary_species before insert or update or delete on biohub.ancillary_species for each row execute procedure tr_audit_trigger(); create trigger audit_investment_action_category before insert or update or delete on biohub.investment_action_category for each row execute procedure tr_audit_trigger(); - create trigger audit_project_type before insert or update or delete on biohub.project_type for each row execute procedure tr_audit_trigger(); + create trigger audit_project_funding_source before insert or update or delete on biohub.project_funding_source for each row execute procedure tr_audit_trigger(); create trigger audit_project_management_actions before insert or update or delete on biohub.project_management_actions for each row execute procedure tr_audit_trigger(); - create trigger audit_project_permit before insert or update or delete on biohub.project_permit for each row execute procedure tr_audit_trigger(); - create trigger audit_user_identity_source before insert or update or delete on biohub.user_identity_source for each row execute procedure tr_audit_trigger(); + create trigger audit_system_user before insert or update or delete on biohub.system_user for each row execute procedure tr_audit_trigger(); diff --git a/database/src/migrations/release.0.7/project_dapi_views.sql b/database/src/migrations/release.0.8/project_dapi_views.sql similarity index 88% rename from database/src/migrations/release.0.7/project_dapi_views.sql rename to database/src/migrations/release.0.8/project_dapi_views.sql index ee93fe7f93..baed67bc2b 100644 --- a/database/src/migrations/release.0.7/project_dapi_views.sql +++ b/database/src/migrations/release.0.8/project_dapi_views.sql @@ -12,10 +12,11 @@ create or replace view no_sample_permit as select * from biohub.no_sample_permit; create or replace view project as select * from biohub.project; create or replace view project_activity as select * from biohub.project_activity; + create or replace view project_attachment as select * from biohub.project_attachment; create or replace view project_climate_initiative as select * from biohub.project_climate_initiative; create or replace view project_first_nation as select * from biohub.project_first_nation; create or replace view project_funding_source as select * from biohub.project_funding_source; - create or replace view project_iucn_action_classificaton as select * from biohub.project_iucn_action_classificaton; + create or replace view project_iucn_action_classification as select * from biohub.project_iucn_action_classification; create or replace view project_management_actions as select * from biohub.project_management_actions; create or replace view project_participation as select * from biohub.project_participation; create or replace view project_permit as select * from biohub.project_permit; @@ -23,6 +24,7 @@ create or replace view project_role as select * from biohub.project_role; create or replace view project_type as select * from biohub.project_type; create or replace view stakeholder_partnership as select * from biohub.stakeholder_partnership; + create or replace view system_constant as select * from biohub.system_constant; create or replace view system_role as select * from biohub.system_role; create or replace view system_user as select * from biohub.system_user; create or replace view system_user_role as select * from biohub.system_user_role; diff --git a/database/src/migrations/release.0.7/project_journal_triggers.sql b/database/src/migrations/release.0.8/project_journal_triggers.sql similarity index 89% rename from database/src/migrations/release.0.7/project_journal_triggers.sql rename to database/src/migrations/release.0.8/project_journal_triggers.sql index 728feaa470..aa64f9411e 100644 --- a/database/src/migrations/release.0.7/project_journal_triggers.sql +++ b/database/src/migrations/release.0.8/project_journal_triggers.sql @@ -5,28 +5,30 @@ drop trigger if exists journal_iucn_conservation_action_level_1_classification on biohub.iucn_conservation_action_level_1_classification; drop trigger if exists journal_focal_species on biohub.focal_species; drop trigger if exists journal_project_activity on biohub.project_activity; + drop trigger if exists journal_no_sample_permit on biohub.no_sample_permit; drop trigger if exists journal_iucn_conservation_action_level_2_subclassification on biohub.iucn_conservation_action_level_2_subclassification; - drop trigger if exists journal_iucn_conservation_action_level_3_subclassification on biohub.iucn_conservation_action_level_3_subclassification; drop trigger if exists journal_project_climate_initiative on biohub.project_climate_initiative; + drop trigger if exists journal_iucn_conservation_action_level_3_subclassification on biohub.iucn_conservation_action_level_3_subclassification; + drop trigger if exists journal_project_attachment on biohub.project_attachment; drop trigger if exists journal_project_first_nation on biohub.project_first_nation; - drop trigger if exists journal_project_funding_source on biohub.project_funding_source; - drop trigger if exists journal_project_iucn_action_classificaton on biohub.project_iucn_action_classificaton; drop trigger if exists journal_management_action_type on biohub.management_action_type; - drop trigger if exists journal_no_sample_permit on biohub.no_sample_permit; + drop trigger if exists journal_project_iucn_action_classification on biohub.project_iucn_action_classification; + drop trigger if exists journal_system_constant on biohub.system_constant; + drop trigger if exists journal_project_type on biohub.project_type; drop trigger if exists journal_project_participation on biohub.project_participation; - drop trigger if exists journal_system_user on biohub.system_user; drop trigger if exists journal_project_role on biohub.project_role; + drop trigger if exists journal_project_permit on biohub.project_permit; drop trigger if exists journal_project_region on biohub.project_region; drop trigger if exists journal_stakeholder_partnership on biohub.stakeholder_partnership; drop trigger if exists journal_system_user_role on biohub.system_user_role; + drop trigger if exists journal_user_identity_source on biohub.user_identity_source; drop trigger if exists journal_system_role on biohub.system_role; drop trigger if exists journal_project on biohub.project; drop trigger if exists journal_ancillary_species on biohub.ancillary_species; drop trigger if exists journal_investment_action_category on biohub.investment_action_category; - drop trigger if exists journal_project_type on biohub.project_type; + drop trigger if exists journal_project_funding_source on biohub.project_funding_source; drop trigger if exists journal_project_management_actions on biohub.project_management_actions; - drop trigger if exists journal_project_permit on biohub.project_permit; - drop trigger if exists journal_user_identity_source on biohub.user_identity_source; + drop trigger if exists journal_system_user on biohub.system_user; create trigger journal_activity after insert or update or delete on biohub.activity for each row execute procedure tr_journal_trigger(); create trigger journal_climate_change_initiative after insert or update or delete on biohub.climate_change_initiative for each row execute procedure tr_journal_trigger(); @@ -35,26 +37,28 @@ create trigger journal_iucn_conservation_action_level_1_classification after insert or update or delete on biohub.iucn_conservation_action_level_1_classification for each row execute procedure tr_journal_trigger(); create trigger journal_focal_species after insert or update or delete on biohub.focal_species for each row execute procedure tr_journal_trigger(); create trigger journal_project_activity after insert or update or delete on biohub.project_activity for each row execute procedure tr_journal_trigger(); + create trigger journal_no_sample_permit after insert or update or delete on biohub.no_sample_permit for each row execute procedure tr_journal_trigger(); create trigger journal_iucn_conservation_action_level_2_subclassification after insert or update or delete on biohub.iucn_conservation_action_level_2_subclassification for each row execute procedure tr_journal_trigger(); - create trigger journal_iucn_conservation_action_level_3_subclassification after insert or update or delete on biohub.iucn_conservation_action_level_3_subclassification for each row execute procedure tr_journal_trigger(); create trigger journal_project_climate_initiative after insert or update or delete on biohub.project_climate_initiative for each row execute procedure tr_journal_trigger(); + create trigger journal_iucn_conservation_action_level_3_subclassification after insert or update or delete on biohub.iucn_conservation_action_level_3_subclassification for each row execute procedure tr_journal_trigger(); + create trigger journal_project_attachment after insert or update or delete on biohub.project_attachment for each row execute procedure tr_journal_trigger(); create trigger journal_project_first_nation after insert or update or delete on biohub.project_first_nation for each row execute procedure tr_journal_trigger(); - create trigger journal_project_funding_source after insert or update or delete on biohub.project_funding_source for each row execute procedure tr_journal_trigger(); - create trigger journal_project_iucn_action_classificaton after insert or update or delete on biohub.project_iucn_action_classificaton for each row execute procedure tr_journal_trigger(); create trigger journal_management_action_type after insert or update or delete on biohub.management_action_type for each row execute procedure tr_journal_trigger(); - create trigger journal_no_sample_permit after insert or update or delete on biohub.no_sample_permit for each row execute procedure tr_journal_trigger(); + create trigger journal_project_iucn_action_classification after insert or update or delete on biohub.project_iucn_action_classification for each row execute procedure tr_journal_trigger(); + create trigger journal_system_constant after insert or update or delete on biohub.system_constant for each row execute procedure tr_journal_trigger(); + create trigger journal_project_type after insert or update or delete on biohub.project_type for each row execute procedure tr_journal_trigger(); create trigger journal_project_participation after insert or update or delete on biohub.project_participation for each row execute procedure tr_journal_trigger(); - create trigger journal_system_user after insert or update or delete on biohub.system_user for each row execute procedure tr_journal_trigger(); create trigger journal_project_role after insert or update or delete on biohub.project_role for each row execute procedure tr_journal_trigger(); + create trigger journal_project_permit after insert or update or delete on biohub.project_permit for each row execute procedure tr_journal_trigger(); create trigger journal_project_region after insert or update or delete on biohub.project_region for each row execute procedure tr_journal_trigger(); create trigger journal_stakeholder_partnership after insert or update or delete on biohub.stakeholder_partnership for each row execute procedure tr_journal_trigger(); create trigger journal_system_user_role after insert or update or delete on biohub.system_user_role for each row execute procedure tr_journal_trigger(); + create trigger journal_user_identity_source after insert or update or delete on biohub.user_identity_source for each row execute procedure tr_journal_trigger(); create trigger journal_system_role after insert or update or delete on biohub.system_role for each row execute procedure tr_journal_trigger(); create trigger journal_project after insert or update or delete on biohub.project for each row execute procedure tr_journal_trigger(); create trigger journal_ancillary_species after insert or update or delete on biohub.ancillary_species for each row execute procedure tr_journal_trigger(); create trigger journal_investment_action_category after insert or update or delete on biohub.investment_action_category for each row execute procedure tr_journal_trigger(); - create trigger journal_project_type after insert or update or delete on biohub.project_type for each row execute procedure tr_journal_trigger(); + create trigger journal_project_funding_source after insert or update or delete on biohub.project_funding_source for each row execute procedure tr_journal_trigger(); create trigger journal_project_management_actions after insert or update or delete on biohub.project_management_actions for each row execute procedure tr_journal_trigger(); - create trigger journal_project_permit after insert or update or delete on biohub.project_permit for each row execute procedure tr_journal_trigger(); - create trigger journal_user_identity_source after insert or update or delete on biohub.user_identity_source for each row execute procedure tr_journal_trigger(); + create trigger journal_system_user after insert or update or delete on biohub.system_user for each row execute procedure tr_journal_trigger(); diff --git a/database/src/migrations/release.0.7/smoketest_release.0.7.sql b/database/src/migrations/release.0.8/smoketest_release.sql similarity index 81% rename from database/src/migrations/release.0.7/smoketest_release.0.7.sql rename to database/src/migrations/release.0.8/smoketest_release.sql index d220db19af..64ffc0e7b4 100644 --- a/database/src/migrations/release.0.7/smoketest_release.0.7.sql +++ b/database/src/migrations/release.0.8/smoketest_release.sql @@ -15,6 +15,9 @@ set search_path to biohub_dapi_v1, biohub, public, topology; select api_set_context('myIDIR', null); +insert into system_constant(constant_name, character_value) values ('CONSTANT_ONE', 'constant_one'); +insert into system_constant(constant_name, numeric_value) values ('CONSTANT_TWO', 1); + do $$ declare __id integer; @@ -51,7 +54,8 @@ begin insert into project_management_actions (p_id, mat_id) values (__id, (select id from management_action_type where name = 'Recovery Action')); insert into project_funding_source (p_id, iac_id, funding_amount, funding_start_date, funding_end_date, funding_source_project_id) values (__id, (select id from investment_action_category where name = 'Action 1'), '$1,000.00', now(), now(), 'test'); --insert into project_funding_source (p_id, iac_id, funding_amount, funding_start_date, funding_end_date) values (__id, 43, '$1,000.00', now(), now()); - insert into project_iucn_action_classificaton (p_id, iucn2_id) values (__id, (select id from iucn_conservation_action_level_2_subclassification where name = 'Species Stewardship')); + insert into project_iucn_action_classification (p_id, iucn3_id) values (__id, (select id from iucn_conservation_action_level_2_subclassification where name = 'Species Stewardship')); + insert into project_attachment (p_id, file_name, title) values (__id, 'test_filename.txt', 'test filename'); end $$; @@ -65,5 +69,7 @@ select count(1) from project_region; select count(1) from project_permit; select count(1) from project_management_actions; select count(1) from project_funding_source; -select count(1) from project_iucn_action_classificaton; +select count(1) from project_iucn_action_classification; +select count(1) from project_attachment; +select count(1) from system_constant; diff --git a/database/src/migrations/release.0.7/tr_audit_trigger.sql b/database/src/migrations/release.0.8/tr_audit_trigger.sql similarity index 100% rename from database/src/migrations/release.0.7/tr_audit_trigger.sql rename to database/src/migrations/release.0.8/tr_audit_trigger.sql diff --git a/database/src/migrations/release.0.7/tr_journal_trigger.sql b/database/src/migrations/release.0.8/tr_journal_trigger.sql similarity index 100% rename from database/src/migrations/release.0.7/tr_journal_trigger.sql rename to database/src/migrations/release.0.8/tr_journal_trigger.sql diff --git a/database/src/migrations/release.0.7/tr_project_funding_source.sql b/database/src/migrations/release.0.8/tr_project_funding_source.sql similarity index 100% rename from database/src/migrations/release.0.7/tr_project_funding_source.sql rename to database/src/migrations/release.0.8/tr_project_funding_source.sql diff --git a/database/src/seeds/01_db_system_users.ts b/database/src/seeds/01_db_system_users.ts index 9e9dc01897..3738eebe85 100644 --- a/database/src/seeds/01_db_system_users.ts +++ b/database/src/seeds/01_db_system_users.ts @@ -5,7 +5,7 @@ const DB_ADMIN = process.env.DB_ADMIN; const systemUsers = [ { identifier: 'aagahche', type: 'IDIR' }, - { identifier: 'cgarrettjones', type: 'IDIR' }, + { identifier: 'cgarrett', type: 'IDIR' }, { identifier: 'istest1', type: 'IDIR' }, { identifier: 'jrpopkin', type: 'IDIR' }, { identifier: 'jxdunsdo', type: 'IDIR' },