/
liquibase-update-to-latest-2.4.x.xml
150 lines (141 loc) · 8.79 KB
/
liquibase-update-to-latest-2.4.x.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?xml version="1.0" encoding="UTF-8"?>
<!--
This Source Code Form is subject to the terms of the Mozilla Public License,
v. 2.0. If a copy of the MPL was not distributed with this file, You can
obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
graphic logo is a trademark of OpenMRS Inc.
-->
<!--
This file contains all changesets that have been introduced on top of either liquibase-snapshots/2.3.x/liquibase-*.xml
or liquibase-updates/2.3.x/liquibase-update-to-latest.xml.
-->
<databaseChangeLog
logicalFilePath="liquibase-update-to-latest.xml"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
<!--
See http://www.liquibase.org/manual/home#available_database_refactorings
for a list of supported elements and attributes
-->
<changeSet id="20190815-Trunk-5412" author="gitacliff">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="order_group" columnName="order_group_reason"/>
</not>
</preConditions>
<comment>Adding "order_group_reason" column to order_group table</comment>
<addColumn tableName="order_group">
<column name="order_group_reason" type="int">
<constraints nullable="true"/>
</column>
</addColumn>
<addForeignKeyConstraint baseTableName="order_group"
baseColumnNames="order_group_reason"
constraintName="order_group_order_group_reason_fk"
referencedTableName="concept"
referencedColumnNames="concept_id" />
</changeSet>
<changeSet id="20190815-Trunk-5650" author="gitacliff">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="order_group" columnName="parent_order_group"/>
</not>
</preConditions>
<comment>Adding "parent_order_group" column to order_group table</comment>
<addColumn tableName="order_group">
<column name="parent_order_group" type="int">
<constraints nullable="true"/>
</column>
</addColumn><addForeignKeyConstraint baseTableName="order_group"
baseColumnNames="parent_order_group"
constraintName="order_group_parent_order_group_fk"
referencedTableName="order_group"
referencedColumnNames="order_group_id" />
</changeSet>
<changeSet id="TRUNK-5728-2020-05-20" author="samuel34">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="conditions" columnName="encounter_id"/>
</not>
</preConditions>
<comment>Adding 'encounter_id' column to 'conditions' table</comment>
<addColumn tableName="conditions">
<column name="encounter_id" type="int">
<constraints nullable="true" />
</column>
</addColumn>
<addForeignKeyConstraint constraintName="conditions_encounter_id_fk"
baseTableName="conditions" baseColumnNames="encounter_id"
referencedTableName="encounter" referencedColumnNames="encounter_id" />
</changeSet>
<changeSet id="20200604-soundex_extension" author="aman" dbms="postgresql">
<comment> Soundex extension for PostgreSQL</comment>
<sql> CREATE EXTENSION IF NOT EXISTS fuzzystrmatch SCHEMA public;</sql>
</changeSet>
<changeSet id="20200715-uuid_ossp_extension" author="aman" dbms="postgresql">
<comment> Extension to use UUID functions with PostgreSQL</comment>
<sql> CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA public;</sql>
</changeSet>
<changeSet id="20200615-postgresql_sequence_update" author="aman" dbms="postgresql">
<comment> Update the sequence values to correct ones after insertions via Liquibase change-sets</comment>
<sql>
SELECT setval('person_person_id_seq', (SELECT MAX(person_id) FROM person)+1);
SELECT setval('person_name_person_name_id_seq', (SELECT MAX(person_name_id) FROM person_name)+1);
SELECT setval('person_attribute_type_person_attribute_type_id_seq', (SELECT MAX(person_attribute_type_id) FROM person_attribute_type)+1);
SELECT setval('relationship_type_relationship_type_id_seq', (SELECT MAX(relationship_type_id) FROM relationship_type)+1);
SELECT setval('users_user_id_seq', (SELECT MAX(user_id) FROM users)+1);
SELECT setval('care_setting_care_setting_id_seq', (SELECT MAX(care_setting_id) FROM care_setting)+1);
SELECT setval('concept_datatype_concept_datatype_id_seq', (SELECT MAX(concept_datatype_id) FROM concept_datatype)+1);
SELECT setval('concept_map_type_concept_map_type_id_seq', (SELECT MAX(concept_map_type_id) FROM concept_map_type)+1);
SELECT setval('concept_stop_word_concept_stop_word_id_seq', (SELECT MAX(concept_stop_word_id) FROM concept_stop_word)+1);
SELECT setval('concept_concept_id_seq', (SELECT MAX(concept_id) FROM concept)+1);
SELECT setval('concept_name_concept_name_id_seq', (SELECT MAX(concept_name_id) FROM concept_name)+1);
SELECT setval('concept_class_concept_class_id_seq', (SELECT MAX(concept_class_id) FROM concept_class)+1);
SELECT setval('encounter_role_encounter_role_id_seq', (SELECT MAX(encounter_role_id) FROM encounter_role)+1);
SELECT setval('field_type_field_type_id_seq', (SELECT MAX(field_type_id) FROM field_type)+1);
SELECT setval('hl7_source_hl7_source_id_seq', (SELECT MAX(hl7_source_id) FROM hl7_source)+1);
SELECT setval('location_location_id_seq', (SELECT MAX(location_id) FROM location)+1);
SELECT setval('order_type_order_type_id_seq', (SELECT MAX(order_type_id) FROM order_type)+1);
SELECT setval('patient_identifier_type_patient_identifier_type_id_seq', (SELECT MAX(patient_identifier_type_id) FROM patient_identifier_type)+1);
</sql>
</changeSet>
<changeSet id="20200622-cascade_delete_concept_comlex" author="aman" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="concept_attributes"/>
</preConditions>
<comment>Updating foreign key concept_attributes to add delete CASCADES</comment>
<dropForeignKeyConstraint baseTableName="concept_complex" constraintName="concept_attributes"/>
<addForeignKeyConstraint baseColumnNames="concept_id" baseTableName="concept_complex" constraintName="concept_attributes" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="NO ACTION" referencedColumnNames="concept_id" referencedTableName="concept"/>
</changeSet>
<changeSet id="20200622-cascade_delete_concept_numeric" author="aman" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="numeric_attributes"/>
</preConditions>
<comment>Updating foreign key numeric_attributes to add delete CASCADES</comment>
<dropForeignKeyConstraint baseTableName="concept_numeric" constraintName="numeric_attributes"/>
<addForeignKeyConstraint baseColumnNames="concept_id" baseTableName="concept_numeric" constraintName="numeric_attributes" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="NO ACTION" referencedColumnNames="concept_id" referencedTableName="concept"/>
</changeSet>
<changeSet id="20200622-cascade_delete_patient" author="aman" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="person_id_for_patient"/>
</preConditions>
<comment>Updating foreign key person_id_for_patient to add delete CASCADES</comment>
<dropForeignKeyConstraint baseTableName="patient" constraintName="person_id_for_patient"/>
<addForeignKeyConstraint baseColumnNames="patient_id" baseTableName="patient" constraintName="person_id_for_patient" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="person_id" referencedTableName="person"/>
</changeSet>
<changeSet id="20200622-cascade_delete_test_order" author="aman" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="test_order_order_id_fk"/>
</preConditions>
<comment>Updating foreign key test_order_order_id_fk to add delete CASCADES</comment>
<dropForeignKeyConstraint baseTableName="test_order" constraintName="test_order_order_id_fk"/>
<addForeignKeyConstraint baseColumnNames="order_id" baseTableName="test_order" constraintName="test_order_order_id_fk" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="NO ACTION" referencedColumnNames="order_id" referencedTableName="orders"/>
</changeSet>
</databaseChangeLog>