7b91bd5b38f6ad6eb4d521ee8fa8a8a5d5e4e505
[cps.git] / cps-ri / src / main / resources / changelog / db / changes / 19-delete-not-required-dataspace-id-from-fragment.yaml
1 # ============LICENSE_START=======================================================
2 # Copyright (C) 2023 Nordix Foundation.
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # SPDX-License-Identifier: Apache-2.0
17 # ============LICENSE_END=========================================================
18
19 databaseChangeLog:
20
21   - changeSet:
22       id: 19-1
23       author: cps
24       changes:
25         - dropIndex:
26             indexName: FKI_FRAGMENT_DATASPACE_ID_FK
27             tableName: fragment
28       rollback:
29         - createIndex:
30             columns:
31               - column:
32                   name: dataspace_id
33             indexName: FKI_FRAGMENT_DATASPACE_ID_FK
34             tableName: fragment
35
36   - changeSet:
37       id: 19-2
38       author: cps
39       changes:
40         - dropUniqueConstraint:
41             constraintName: fragment_dataspace_id_anchor_id_xpath_key
42             tableName: fragment
43         - addUniqueConstraint:
44             columnNames: anchor_id, xpath
45             constraintName: fragment_anchor_id_xpath_key
46             tableName: fragment
47       rollback:
48         - dropUniqueConstraint:
49             constraintName: fragment_anchor_id_xpath_key
50             tableName: fragment
51         - addUniqueConstraint:
52             columnNames: dataspace_id, anchor_id, xpath
53             constraintName: fragment_dataspace_id_anchor_id_xpath_key
54             tableName: fragment
55
56   - changeSet:
57       id: 19-3
58       author: cps
59       changes:
60         - dropForeignKeyConstraint:
61             baseTableName: fragment
62             constraintName: fragment_dataspace_id_fkey
63       rollback:
64         - addForeignKeyConstraint:
65             baseColumnNames: dataspace_id
66             baseTableName: fragment
67             constraintName: fragment_dataspace_id_fkey
68             deferrable: false
69             initiallyDeferred: false
70             onDelete: NO ACTION
71             onUpdate: NO ACTION
72             referencedColumnNames: id
73             referencedTableName: dataspace
74             validate: true
75
76   - changeSet:
77       id: 19-4
78       author: cps
79       changes:
80         - dropColumn:
81             columnName: dataspace_id
82             tableName: fragment
83       rollback:
84         - addColumn:
85             tableName: fragment
86             columns:
87               - column:
88                   name: dataspace_id
89                   type: INTEGER
90         - sqlFile:
91             path: changelog/db/changes/19-repopulate-dataspace-id-for-rollback.sql
92         - addNotNullConstraint:
93             tableName: fragment
94             columnName: dataspace_id
95             columnDataType: INTEGER
96
97   - changeSet:
98       id: 19-5
99       author: cps
100       changes:
101         - addNotNullConstraint:
102             tableName: fragment
103             columnName: anchor_id
104             columnDataType: BIGINT
105       rollback:
106         - dropNotNullConstraint:
107             tableName: fragment
108             columnName: anchor_id
109             columnDataType: BIGINT