-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create separate sequence for each entity (#327) * Postgre flyway fix * SQL Server flyway fix * Oracle flyway fix
- Loading branch information
1 parent
a4058f5
commit 7576115
Showing
11 changed files
with
462 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
src/main/resources/db/migration/oracle/V2.2.5.20180215105415__separate-sequences.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
-- cca | ||
DECLARE | ||
val INTEGER; | ||
stmt VARCHAR2(255); | ||
BEGIN | ||
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.cca_sequence START WITH '; | ||
SELECT nvl2(max(cca_id), max(cca_id) + 1, 1) INTO val FROM ${ohdsiSchema}.cca; | ||
EXECUTE IMMEDIATE stmt || val; | ||
END; | ||
/ | ||
|
||
-- cohort_definition | ||
DECLARE | ||
val INTEGER; | ||
stmt VARCHAR2(255); | ||
BEGIN | ||
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.cohort_definition_sequence START WITH '; | ||
SELECT nvl2(max(id), max(id) + 1, 1) INTO val FROM ${ohdsiSchema}.cohort_definition; | ||
EXECUTE IMMEDIATE stmt || val; | ||
END; | ||
/ | ||
|
||
DROP SEQUENCE ${ohdsiSchema}.CONCEPT_SET_SEQUENCE; | ||
|
||
-- concept_set | ||
DECLARE | ||
val INTEGER; | ||
stmt VARCHAR2(255); | ||
BEGIN | ||
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.concept_set_sequence START WITH '; | ||
SELECT nvl2(max(concept_set_id), max(concept_set_id) + 1, 1) INTO val FROM ${ohdsiSchema}.concept_set; | ||
EXECUTE IMMEDIATE stmt || val; | ||
END; | ||
/ | ||
|
||
DROP SEQUENCE ${ohdsiSchema}.CONCEPT_SET_ITEM_SEQUENCE; | ||
|
||
-- concept_set_item | ||
DECLARE | ||
val INTEGER; | ||
stmt VARCHAR2(255); | ||
BEGIN | ||
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.concept_set_item_sequence START WITH '; | ||
SELECT nvl2(max(concept_set_item_id), max(concept_set_item_id) + 1, 1) INTO val FROM ${ohdsiSchema}.concept_set_item; | ||
EXECUTE IMMEDIATE stmt || val; | ||
END; | ||
/ | ||
|
||
-- concept_set_negative_controls | ||
DECLARE | ||
val INTEGER; | ||
stmt VARCHAR2(255); | ||
BEGIN | ||
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.negative_controls_sequence START WITH '; | ||
SELECT nvl2(max(id), max(id) + 1, 1) INTO val FROM ${ohdsiSchema}.concept_set_negative_controls; | ||
EXECUTE IMMEDIATE stmt || val; | ||
END; | ||
/ | ||
|
||
-- feasibility_study | ||
DECLARE | ||
val INTEGER; | ||
stmt VARCHAR2(255); | ||
BEGIN | ||
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.feasibility_study_sequence START WITH '; | ||
SELECT nvl2(max(id), max(id) + 1, 1) INTO val FROM ${ohdsiSchema}.feasibility_study; | ||
EXECUTE IMMEDIATE stmt || val; | ||
END; | ||
/ | ||
|
||
-- ir_analysis | ||
DECLARE | ||
val INTEGER; | ||
stmt VARCHAR2(255); | ||
BEGIN | ||
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.ir_analysis_sequence START WITH '; | ||
SELECT nvl2(max(id), max(id) + 1, 1) INTO val FROM ${ohdsiSchema}.ir_analysis; | ||
EXECUTE IMMEDIATE stmt || val; | ||
END; | ||
/ | ||
|
||
-- plp | ||
DECLARE | ||
val INTEGER; | ||
stmt VARCHAR2(255); | ||
BEGIN | ||
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.plp_sequence START WITH '; | ||
SELECT nvl2(max(plp_id), max(plp_id) + 1, 1) INTO val FROM ${ohdsiSchema}.plp; | ||
EXECUTE IMMEDIATE stmt || val; | ||
END; | ||
/ |
23 changes: 23 additions & 0 deletions
23
src/main/resources/db/migration/postgresql/V2.2.5.20180215105415__separate-sequences.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
CREATE SEQUENCE ${ohdsiSchema}.cca_sequence; | ||
SELECT setval('${ohdsiSchema}.cca_sequence', coalesce(max(cca_id), 1)) FROM ${ohdsiSchema}.cca; | ||
|
||
CREATE SEQUENCE ${ohdsiSchema}.cohort_definition_sequence; | ||
SELECT setval('${ohdsiSchema}.cohort_definition_sequence', coalesce(max(id), 1)) FROM ${ohdsiSchema}.cohort_definition; | ||
|
||
-- concept_set_sequence already exists - no need to create | ||
SELECT setval('${ohdsiSchema}.concept_set_sequence', coalesce(max(concept_set_id), 1)) FROM ${ohdsiSchema}.concept_set; | ||
|
||
-- concept_set_item_sequence already exists - no need to create | ||
SELECT setval('${ohdsiSchema}.concept_set_item_sequence', coalesce(max(concept_set_item_id), 1)) FROM ${ohdsiSchema}.concept_set_item; | ||
|
||
-- negative_controls_sequence already exists - no need to create | ||
SELECT setval('${ohdsiSchema}.negative_controls_sequence', coalesce(max(id), 1)) FROM ${ohdsiSchema}.concept_set_negative_controls; | ||
|
||
CREATE SEQUENCE ${ohdsiSchema}.feasibility_study_sequence; | ||
SELECT setval('${ohdsiSchema}.feasibility_study_sequence', coalesce(max(id), 1)) FROM ${ohdsiSchema}.feasibility_study; | ||
|
||
CREATE SEQUENCE ${ohdsiSchema}.ir_analysis_sequence; | ||
SELECT setval('${ohdsiSchema}.ir_analysis_sequence', coalesce(max(id), 1)) FROM ${ohdsiSchema}.ir_analysis; | ||
|
||
CREATE SEQUENCE ${ohdsiSchema}.plp_sequence; | ||
SELECT setval('${ohdsiSchema}.plp_sequence', coalesce(max(plp_id), 1)) FROM ${ohdsiSchema}.plp; |
Oops, something went wrong.