From a721214b08e76a77c81e4d80a5a12bb9490dcc0f Mon Sep 17 00:00:00 2001 From: Vitaly Koulakov Date: Thu, 23 Jan 2020 12:02:22 +0300 Subject: [PATCH] Resolves Mismatch in pathway_event_cohort DDL (#1419) * WebAPI-975 Extract Cohort Characterization analysis to external package * fixes SQL injection vulnerability * Resolves Mismatch in pathway_event_cohort DDL between sql server and postgresql. --- .../V2.6.0.20180906220021__pathway_analysis.sql | 1 - ...solete_field_pathway_event_cohort_deleted_id.sql | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/db/migration/sqlserver/V2.8.0.20200116134252__remove_obsolete_field_pathway_event_cohort_deleted_id.sql diff --git a/src/main/resources/db/migration/sqlserver/V2.6.0.20180906220021__pathway_analysis.sql b/src/main/resources/db/migration/sqlserver/V2.6.0.20180906220021__pathway_analysis.sql index 3e8ba3a951..0510ac5591 100644 --- a/src/main/resources/db/migration/sqlserver/V2.6.0.20180906220021__pathway_analysis.sql +++ b/src/main/resources/db/migration/sqlserver/V2.6.0.20180906220021__pathway_analysis.sql @@ -38,7 +38,6 @@ CREATE TABLE ${ohdsiSchema}.pathway_event_cohort name VARCHAR(255) NOT NULL, cohort_definition_id INTEGER NOT NULL, pathway_analysis_id INTEGER NOT NULL, - is_deleted INTEGER DEFAULT 0, CONSTRAINT [PK_pathway_event_cohort] PRIMARY KEY (id), CONSTRAINT FK_pec_cd_id FOREIGN KEY (cohort_definition_id) diff --git a/src/main/resources/db/migration/sqlserver/V2.8.0.20200116134252__remove_obsolete_field_pathway_event_cohort_deleted_id.sql b/src/main/resources/db/migration/sqlserver/V2.8.0.20200116134252__remove_obsolete_field_pathway_event_cohort_deleted_id.sql new file mode 100644 index 0000000000..5cdedb36d9 --- /dev/null +++ b/src/main/resources/db/migration/sqlserver/V2.8.0.20200116134252__remove_obsolete_field_pathway_event_cohort_deleted_id.sql @@ -0,0 +1,13 @@ +-- at first removing default value +declare @command nvarchar(1000) +select @command = 'ALTER TABLE ${ohdsiSchema}.pathway_event_cohort DROP CONSTRAINT IF EXISTS ' + d.name +from sys.tables t + join sys.default_constraints d on d.parent_object_id = t.object_id + join sys.columns c on c.object_id = t.object_id and c.column_id = d.parent_column_id +where + t.name = 'pathway_event_cohort' + and t.schema_id = schema_id('${ohdsiSchema}') + and c.name = 'is_deleted'; +execute (@command) + +ALTER TABLE ${ohdsiSchema}.pathway_event_cohort DROP COLUMN IF EXISTS is_deleted; \ No newline at end of file