0c881b802e0465835aa8ab9873b3d2618ce87af3
[cps.git] / integration-test / src / test / resources / liquibase / test-changelog.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 # ============LICENSE_END=========================================================
16
17 databaseChangeLog:
18   - changeSet:
19       id: 1-1
20       author: cps
21       changes:
22         - createTable:
23             columns:
24               - column:
25                   autoIncrement: true
26                   constraints:
27                     nullable: false
28                     primaryKey: true
29                     primaryKeyName: anchor_pkey
30                   name: id
31                   type: BIGINT
32               - column:
33                   name: name
34                   type: TEXT
35               - column:
36                   name: schema_set_id
37                   type: INTEGER
38               - column:
39                   constraints:
40                     nullable: false
41                   name: dataspace_id
42                   type: INTEGER
43             tableName: anchor
44   - changeSet:
45       id: 1-2
46       author: cps
47       changes:
48         - createTable:
49             columns:
50               - column:
51                   constraints:
52                     nullable: false
53                   name: from_fragment_id
54                   type: BIGINT
55               - column:
56                   constraints:
57                     nullable: false
58                   name: to_fragment_id
59                   type: BIGINT
60               - column:
61                   constraints:
62                     nullable: false
63                   name: relation_type_id
64                   type: INTEGER
65               - column:
66                   constraints:
67                     nullable: false
68                   name: from_rel_xpath
69                   type: TEXT
70               - column:
71                   constraints:
72                     nullable: false
73                   name: to_rel_xpath
74                   type: TEXT
75             tableName: relation
76   - changeSet:
77       id: 1-3
78       author: cps
79       changes:
80         - createTable:
81             columns:
82               - column:
83                   constraints:
84                     nullable: false
85                   name: relation_type
86                   type: TEXT
87               - column:
88                   autoIncrement: true
89                   constraints:
90                     nullable: false
91                     primaryKey: true
92                     primaryKeyName: relation_type_pkey
93                   name: id
94                   type: INTEGER
95             tableName: relation_type
96   - changeSet:
97       id: 1-4
98       author: cps
99       changes:
100         - createTable:
101             columns:
102               - column:
103                   autoIncrement: true
104                   constraints:
105                     nullable: false
106                     primaryKey: true
107                     primaryKeyName: fragment_pkey
108                   name: id
109                   type: BIGINT
110               - column:
111                   constraints:
112                     nullable: false
113                   name: xpath
114                   type: TEXT
115               - column:
116                   name: attributes
117                   type: JSONB
118               - column:
119                   name: anchor_id
120                   type: BIGINT
121               - column:
122                   name: parent_id
123                   type: BIGINT
124               - column:
125                   constraints:
126                     nullable: false
127                   name: dataspace_id
128                   type: INTEGER
129               - column:
130                   name: schema_node_id
131                   type: INTEGER
132             tableName: fragment
133   - changeSet:
134       id: 1-5
135       author: cps
136       changes:
137         - createTable:
138             columns:
139               - column:
140                   autoIncrement: true
141                   constraints:
142                     nullable: false
143                     primaryKey: true
144                     primaryKeyName: schema_set_pkey
145                   name: id
146                   type: INTEGER
147               - column:
148                   constraints:
149                     nullable: false
150                   name: name
151                   type: TEXT
152               - column:
153                   constraints:
154                     nullable: false
155                   name: dataspace_id
156                   type: BIGINT
157             tableName: schema_set
158   - changeSet:
159       id: 1-6
160       author: cps
161       changes:
162         - createTable:
163             columns:
164               - column:
165                   autoIncrement: true
166                   constraints:
167                     nullable: false
168                     primaryKey: true
169                     primaryKeyName: yang_resource_pkey
170                   name: id
171                   type: INTEGER
172               - column:
173                   constraints:
174                     nullable: false
175                   name: name
176                   type: TEXT
177               - column:
178                   constraints:
179                     nullable: false
180                   name: content
181                   type: TEXT
182               - column:
183                   constraints:
184                     nullable: false
185                   name: checksum
186                   type: TEXT
187             tableName: yang_resource
188   - changeSet:
189       id: 1-7
190       author: cps
191       changes:
192         - createTable:
193             columns:
194               - column:
195                   autoIncrement: true
196                   constraints:
197                     nullable: false
198                     primaryKey: true
199                     primaryKeyName: dataspace_pkey
200                   name: id
201                   type: INTEGER
202               - column:
203                   constraints:
204                     nullable: false
205                   name: name
206                   type: TEXT
207             tableName: dataspace
208   - changeSet:
209       id: 1-8
210       author: cps
211       changes:
212         - createTable:
213             columns:
214               - column:
215                   constraints:
216                     nullable: false
217                   name: schema_node_identifier
218                   type: TEXT
219               - column:
220                   autoIncrement: true
221                   constraints:
222                     nullable: false
223                     primaryKey: true
224                     primaryKeyName: schema_node_pkey
225                   name: id
226                   type: INTEGER
227             tableName: schema_node
228   - changeSet:
229       id: 1-9
230       author: cps
231       changes:
232         - createTable:
233             columns:
234               - column:
235                   constraints:
236                     nullable: false
237                   name: schema_set_id
238                   type: BIGINT
239               - column:
240                   constraints:
241                     nullable: false
242                   name: yang_resource_id
243                   type: BIGINT
244             tableName: schema_set_yang_resources
245   - changeSet:
246       id: 1-10
247       author: cps
248       changes:
249         - createIndex:
250             columns:
251               - column:
252                   name: schema_set_id
253             indexName: FKI_ANCHOR_SCHEMA_SET_ID_FK
254             tableName: anchor
255   - changeSet:
256       id: 1-11
257       author: cps
258       changes:
259         - addUniqueConstraint:
260             columnNames: dataspace_id, name
261             constraintName: anchor_dataspace_id_name_key
262             tableName: anchor
263   - changeSet:
264       id: 1-12
265       author: cps
266       changes:
267         - addForeignKeyConstraint:
268             baseColumnNames: anchor_id
269             baseTableName: fragment
270             constraintName: fragment_anchor_id_fkey
271             deferrable: false
272             initiallyDeferred: false
273             onDelete: NO ACTION
274             onUpdate: NO ACTION
275             referencedColumnNames: id
276             referencedTableName: anchor
277             validate: true
278   - changeSet:
279       id: 1-13
280       author: cps
281       changes:
282         - createIndex:
283             columns:
284               - column:
285                   name: from_fragment_id
286             indexName: FKI_RELATIONS_FROM_ID_FK
287             tableName: relation
288   - changeSet:
289       id: 1-14
290       author: cps
291       changes:
292         - createIndex:
293             columns:
294               - column:
295                   name: to_fragment_id
296             indexName: FKI_RELATIONS_TO_ID_FK
297             tableName: relation
298   - changeSet:
299       id: 1-15
300       author: cps
301       changes:
302         - createIndex:
303             columns:
304               - column:
305                   name: relation_type_id
306             indexName: FKI_RELATION_TYPE_ID_FK
307             tableName: relation
308   - changeSet:
309       id: 1-16
310       author: cps
311       changes:
312         - addPrimaryKey:
313             columnNames: to_fragment_id, from_fragment_id, relation_type_id
314             constraintName: relation_pkey
315             tableName: relation
316   - changeSet:
317       id: 1-17
318       author: cps
319       changes:
320         - createIndex:
321             columns:
322               - column:
323                   name: anchor_id
324             indexName: FKI_FRAGMENT_ANCHOR_ID_FK
325             tableName: fragment
326   - changeSet:
327       id: 1-18
328       author: cps
329       changes:
330         - createIndex:
331             columns:
332               - column:
333                   name: dataspace_id
334             indexName: FKI_FRAGMENT_DATASPACE_ID_FK
335             tableName: fragment
336   - changeSet:
337       id: 1-19
338       author: cps
339       changes:
340         - createIndex:
341             columns:
342               - column:
343                   name: parent_id
344             indexName: FKI_FRAGMENT_PARENT_ID_FK
345             tableName: fragment
346   - changeSet:
347       id: 1-20
348       author: cps
349       changes:
350         - createIndex:
351             columns:
352               - column:
353                   name: schema_node_id
354             indexName: FKI_SCHEMA_NODE_ID_TO_ID
355             tableName: fragment
356   - changeSet:
357       id: 1-21
358       author: cps
359       changes:
360         - createIndex:
361             columns:
362               - column:
363                   name: xpath
364               - column:
365                   name: dataspace_id
366             indexName: UQ_FRAGMENT_XPATH
367             tableName: fragment
368             unique: true
369   - changeSet:
370       id: 1-22
371       author: cps
372       changes:
373         - addUniqueConstraint:
374             columnNames: dataspace_id, anchor_id, xpath
375             constraintName: fragment_dataspace_id_anchor_id_xpath_key
376             tableName: fragment
377   - changeSet:
378       id: 1-23
379       author: cps
380       changes:
381         - addForeignKeyConstraint:
382             baseColumnNames: from_fragment_id
383             baseTableName: relation
384             constraintName: relation_from_fragment_id_fkey
385             deferrable: false
386             initiallyDeferred: false
387             onDelete: NO ACTION
388             onUpdate: NO ACTION
389             referencedColumnNames: id
390             referencedTableName: fragment
391             validate: true
392   - changeSet:
393       id: 1-24
394       author: cps
395       changes:
396         - addForeignKeyConstraint:
397             baseColumnNames: to_fragment_id
398             baseTableName: relation
399             constraintName: relation_to_fragment_id_fkey
400             deferrable: false
401             initiallyDeferred: false
402             onDelete: NO ACTION
403             onUpdate: NO ACTION
404             referencedColumnNames: id
405             referencedTableName: fragment
406             validate: true
407   - changeSet:
408       id: 1-25
409       author: cps
410       changes:
411         - addUniqueConstraint:
412             columnNames: name, dataspace_id
413             constraintName: schema_set_name_dataspace_id_key
414             tableName: schema_set
415   - changeSet:
416       id: 1-26
417       author: cps
418       changes:
419         - addForeignKeyConstraint:
420             baseColumnNames: schema_set_id
421             baseTableName: schema_set_yang_resources
422             constraintName: schema_set_resource
423             deferrable: false
424             initiallyDeferred: false
425             onDelete: CASCADE
426             onUpdate: NO ACTION
427             referencedColumnNames: id
428             referencedTableName: schema_set
429             validate: true
430   - changeSet:
431       id: 1-27
432       author: cps
433       changes:
434         - addUniqueConstraint:
435             columnNames: checksum
436             constraintName: yang_resource_checksum_key
437             tableName: yang_resource
438   - changeSet:
439       id: 1-28
440       author: cps
441       changes:
442         - addUniqueConstraint:
443             columnNames: name
444             constraintName: UQ_NAME
445             tableName: dataspace
446   - changeSet:
447       id: 1-29
448       author: cps
449       changes:
450         - addForeignKeyConstraint:
451             baseColumnNames: dataspace_id
452             baseTableName: fragment
453             constraintName: fragment_dataspace_id_fkey
454             deferrable: false
455             initiallyDeferred: false
456             onDelete: NO ACTION
457             onUpdate: NO ACTION
458             referencedColumnNames: id
459             referencedTableName: dataspace
460             validate: true
461   - changeSet:
462       id: 1-30
463       author: cps
464       changes:
465         - addForeignKeyConstraint:
466             baseColumnNames: dataspace_id
467             baseTableName: schema_set
468             constraintName: schema_set_dataspace
469             deferrable: false
470             initiallyDeferred: false
471             onDelete: CASCADE
472             onUpdate: CASCADE
473             referencedColumnNames: id
474             referencedTableName: dataspace
475             validate: true
476   - changeSet:
477       id: 1-31
478       author: cps
479       changes:
480         - createIndex:
481             columns:
482               - column:
483                   name: schema_node_identifier
484             indexName: PERF_SCHEMA_NODE_SCHEMA_NODE_ID
485             tableName: schema_node
486   - changeSet:
487       id: 1-32
488       author: cps
489       changes:
490         - addForeignKeyConstraint:
491             baseColumnNames: yang_resource_id
492             baseTableName: schema_set_yang_resources
493             constraintName: schema_set_yang_resources_yang_resource_id_fkey
494             deferrable: false
495             initiallyDeferred: false
496             onDelete: NO ACTION
497             onUpdate: NO ACTION
498             referencedColumnNames: id
499             referencedTableName: yang_resource
500             validate: true
501   - changeSet:
502       id: 1-33
503       author: cps
504       changes:
505         - addForeignKeyConstraint:
506             baseColumnNames: dataspace_id
507             baseTableName: anchor
508             constraintName: anchor_dataspace_id_fkey
509             deferrable: false
510             initiallyDeferred: false
511             onDelete: NO ACTION
512             onUpdate: NO ACTION
513             referencedColumnNames: id
514             referencedTableName: dataspace
515             validate: true
516   - changeSet:
517       id: 1-34
518       author: cps
519       changes:
520         - addForeignKeyConstraint:
521             baseColumnNames: schema_set_id
522             baseTableName: anchor
523             constraintName: anchor_schema_set_id_fkey
524             deferrable: false
525             initiallyDeferred: false
526             onDelete: NO ACTION
527             onUpdate: NO ACTION
528             referencedColumnNames: id
529             referencedTableName: schema_set
530             validate: true
531   - changeSet:
532       id: 1-35
533       author: cps
534       changes:
535         - addForeignKeyConstraint:
536             baseColumnNames: relation_type_id
537             baseTableName: relation
538             constraintName: relation_relation_type_id_fkey
539             deferrable: false
540             initiallyDeferred: false
541             onDelete: NO ACTION
542             onUpdate: NO ACTION
543             referencedColumnNames: id
544             referencedTableName: relation_type
545             validate: true
546   - changeSet:
547       id: 1-36
548       author: cps
549       changes:
550         - addForeignKeyConstraint:
551             baseColumnNames: parent_id
552             baseTableName: fragment
553             constraintName: fragment_parent_id_fkey
554             deferrable: false
555             initiallyDeferred: false
556             onDelete: NO ACTION
557             onUpdate: NO ACTION
558             referencedColumnNames: id
559             referencedTableName: fragment
560             validate: true
561   - changeSet:
562       id: 1-37
563       author: cps
564       changes:
565         - addForeignKeyConstraint:
566             baseColumnNames: schema_node_id
567             baseTableName: fragment
568             constraintName: fragment_schema_node_id_fkey
569             deferrable: false
570             initiallyDeferred: false
571             onDelete: NO ACTION
572             onUpdate: NO ACTION
573             referencedColumnNames: id
574             referencedTableName: schema_node
575             validate: true
576
577
578   - changeSet:
579       id: 1-38
580       label: add-module-name-and-revision-column
581       author: cps
582       changes:
583         - addColumn:
584             tableName: yang_resource
585             columns:
586               - column:
587                   name: module_name
588                   type: TEXT
589               - column:
590                   name: revision
591                   type: TEXT
592
593   - changeSet:
594       id: 1-39
595       label: update-previous-data-module-name-and-revision
596       author: cps
597       changes:
598         - sql:
599             sql: update yang_resource set module_name = 'dummy_module_name', revision = '2021-08-04' where module_name is null and revision is null
600       rollback:
601         sql: update yang_resource set module_name = null, revision = null where module_name = 'dummy_module_name' and revision = '2021-08-04'
602
603   - changeSet:
604       author: cps
605       label: yang-resource-rename-column
606       id: 1-40
607       changes:
608         - renameColumn:
609             tableName: yang_resource
610             columnDataType: TEXT
611             oldColumnName: name
612             newColumnName: file_name
613       rollback:
614         - sql:
615             sql: alter table yang_resource rename column file_name to name