liquibase-changeLog.yml 37.6 KB
Newer Older
1
2
databaseChangeLog:

Matija Obreza's avatar
Matija Obreza committed
3
# Application Blocks:    upgrade user to BasicUser
4
- changeSet:
Matija Obreza's avatar
Matija Obreza committed
5
6
    id:                  1495959628118-1
    author:              matijaobreza (generated)
7
8
    changes:
    - renameTable:
Matija Obreza's avatar
Matija Obreza committed
9
10
        newTableName:    userrole
        oldTableName:    user_role
11
12

- changeSet:
Matija Obreza's avatar
Matija Obreza committed
13
14
    id:                  1495959628118-3
    author:              matijaobreza (generated)
15
16
    changes:
    - renameColumn:
Matija Obreza's avatar
Matija Obreza committed
17
18
19
20
21
        columnDataType:  varchar(255)
        newColumnName:   fullName
        oldColumnName:   name
        remarks:         Full name of user
        tableName:       user
22
23

- changeSet:
Matija Obreza's avatar
Matija Obreza committed
24
25
    id:                  1495959628118-5
    author:              matijaobreza (generated)
26
27
    changes:
    - addColumn:
Matija Obreza's avatar
Matija Obreza committed
28
        tableName:       user
29
30
31
        columns:
        - column:
            constraints:
Matija Obreza's avatar
Matija Obreza committed
32
33
34
              nullable:  false
            name:        active
            type:        bit
35
        - column:
Matija Obreza's avatar
Matija Obreza committed
36
37
            name:        createdBy
            type:        bigint
38
        - column:
Matija Obreza's avatar
Matija Obreza committed
39
40
            name:        lastModifiedBy
            type:        bigint
41
        - column:
Matija Obreza's avatar
Matija Obreza committed
42
43
            name:        lastModifiedDate
            type:        datetime
44
        - column:
Matija Obreza's avatar
Matija Obreza committed
45
46
            name:        passwordExpires
            type:        datetime
47
        - column:
Matija Obreza's avatar
Matija Obreza committed
48
49
            name:        shortName
            type:        varchar(20)
50
        - column:
Matija Obreza's avatar
Matija Obreza committed
51
52
            name:        version
            type:        integer
53
54

- changeSet:
Matija Obreza's avatar
Matija Obreza committed
55
56
    id:                  1495959628118-6
    author:              mobreza
57
58
    changes:
    - sql:
Matija Obreza's avatar
Matija Obreza committed
59
60
        comment:         Migrate user.enabled to user.active = user.enabled;
        sql:             update user set active = enabled;
61
62

- changeSet:
Matija Obreza's avatar
Matija Obreza committed
63
64
    id:                  1495959628118-7
    author:              matijaobreza (generated)
65
66
    changes:
    - renameColumn:
Matija Obreza's avatar
Matija Obreza committed
67
68
69
70
71
        columnDataType:  varchar(20)
        newColumnName:   accountType
        oldColumnName:   loginType
        remarks:         Account type
        tableName:       user
72
    - sql:
Matija Obreza's avatar
Matija Obreza committed
73
74
        comment:         loginType#PASSWORD is changed to accountType#LOCAL
        sql:             update user set accountType = 'LOCAL' where accountType = 'PASSWORD';
75
76

- changeSet:
Matija Obreza's avatar
Matija Obreza committed
77
78
    id:                  1495959628118-8
    author:              mobreza
79
80
    changes:
    - sql:
Matija Obreza's avatar
Matija Obreza committed
81
82
        comment:         Assign user.version
        sql:             update user set version = 1 where version is null;
83
84

- changeSet:
Matija Obreza's avatar
Matija Obreza committed
85
86
    id:                  1495959628118-9
    author:              matijaobreza (generated)
87
88
    changes:
    - addColumn:
Matija Obreza's avatar
Matija Obreza committed
89
        tableName:       user
90
91
        columns:
        - column:
Matija Obreza's avatar
Matija Obreza committed
92
93
            name:        createdDate
            type:        datetime
94
        - column:
Matija Obreza's avatar
Matija Obreza committed
95
96
            name:        accountExpires
            type:        datetime
97
98

- changeSet:
Matija Obreza's avatar
Matija Obreza committed
99
100
    id:                  1495959628118-10
    author:              matijaobreza (generated)
101
102
    changes:
    - addUniqueConstraint:
Matija Obreza's avatar
Matija Obreza committed
103
104
105
        columnNames:     shortName
        constraintName:  UC_USERSHORTNAME_COL
        tableName:       user
106
107

- changeSet:
Matija Obreza's avatar
Matija Obreza committed
108
109
    id:                  1495959628118-11
    author:              matijaobreza (generated)
110
111
    changes:
    - renameColumn:
Matija Obreza's avatar
Matija Obreza committed
112
113
114
115
        columnDataType:  bigint
        oldColumnName:   user_id
        newColumnName:   userId
        tableName:       userrole
116
    - renameColumn:
Matija Obreza's avatar
Matija Obreza committed
117
118
119
120
        columnDataType:  varchar(50)
        oldColumnName:   user_role
        newColumnName:   role
        tableName:       userrole
121
122
123

# ClassPK
- changeSet:
Matija Obreza's avatar
Matija Obreza committed
124
125
    id:                  1496418311575-1
    author:              matijaobreza
126
127
    changes:
    - renameTable:
Matija Obreza's avatar
Matija Obreza committed
128
129
        newTableName:    classpk
        oldTableName:    classname
130
131

- changeSet:
Matija Obreza's avatar
Matija Obreza committed
132
133
    id:                  1496418311575-2
    author:              matijaobreza (generated)
134
135
    changes:
    - renameColumn:
Matija Obreza's avatar
Matija Obreza committed
136
137
138
139
        columnDataType:  varchar(250)
        oldColumnName:   className
        newColumnName:   classname
        tableName:       classpk
140
141
142

# Country Boundingbox
- changeSet:
Matija Obreza's avatar
Matija Obreza committed
143
144
    id:                  1496779094288-1
    author:              matijaobreza (generated)
145
146
    changes:
    - addColumn:
Matija Obreza's avatar
Matija Obreza committed
147
        tableName:       country
148
149
        columns:
        - column:
Matija Obreza's avatar
Matija Obreza committed
150
151
            name:        minLongitude
            type:        double
152
        - column:
Matija Obreza's avatar
Matija Obreza committed
153
154
            name:        maxLongitude
            type:        double
155
        - column:
Matija Obreza's avatar
Matija Obreza committed
156
157
            name:        minLatitude
            type:        double
158
        - column:
Matija Obreza's avatar
Matija Obreza committed
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
            name:        maxLatitude
            type:        double

# System accounts
- changeSet:
    id:                  1497558768000-1
    author:              matijaobreza (generated)
    changes:
    - sql:
        comment:         if user#sys==1 convert to accountType#SYSTEM
        sql:             update user set accountType = 'SYSTEM' where sys = 1;
    - dropColumn:
        tableName:       user
        columnName:      sys
    rollback:
    - addColumn:
        tableName:       user
        columnName:      sys
        type:            boolean
    - sql:
        comment:         accountType#SYSTEM to user#sys==1
        sql:             update user set sys = 1 where accountType = 'SYSTEM';
Maxym Borodenko's avatar
Maxym Borodenko committed
181
182
183
184
185
186
187
188
189
190
191

- changeSet:
    id:                  1497558768000-2
    author:              maxymborodenko (generated)
    changes:
    - addColumn:
        tableName:       accession
        columns:
        - column:
            name:        doi
            type:        varchar(255)
192
193
194
195
    rollback:
    - dropColumn:
        tableName:       accession
        columnName:      doi
Maxym Borodenko's avatar
Maxym Borodenko committed
196
197

- changeSet:
198
199
    id:                  1497558768000-3
    author:              maxymborodenko (generated)
Maxym Borodenko's avatar
Maxym Borodenko committed
200
201
    changes:
    - addUniqueConstraint:
202
203
204
205
206
207
208
        columnNames:     doi
        constraintName:  UQ_accession_doi
        tableName:       accession
    rollback:
    - dropUniqueConstraint:
        tableName:       accession
        constraintName:  UQ_accession_doi
Maxym Borodenko's avatar
Maxym Borodenko committed
209
210
211
212
213
214
215
216
217
218

- changeSet:
    id:                  1497558768000-4
    author:              maxymborodenko (generated)
    changes:
    - addColumn:
        tableName:       accessionhistoric
        columns:
        - column:
            name:        doi
219
            type:        varchar(255)
Maxym Borodenko's avatar
Maxym Borodenko committed
220
221
222
223
224
225
226
227
228
229

- changeSet:
    id:                  1505830865186-1
    author:              maxymborodenko (generated)
    changes:
    - addColumn:
        tableName:       user
        columns:
        - column:
            name:        ftpPassword
Matija Obreza's avatar
Matija Obreza committed
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
            type:        varchar(60)

# file-repository:0.9-SNAPSHOT
- changeSet:
    id:                  1506155384557-1
    author:              mobreza (generated)
    changes:
    - addColumn:
        columns:
        - column:
            constraints:
              nullable:  false
            name:        active
            type:        BIT(1)
        - column:
            constraints:
              nullable:  false
            name:        size
            type:        INT(10)
        - column:
            name:        lastModifiedBy
            type:        BIGINT(19)
        - column:
            name:        createdBy
            type:        BIGINT(19)
        tableName:       repositorydocument
    - addNotNullConstraint:
        columnDataType:  varchar(32)
        columnName:      md5Sum
        tableName:       repositorydocument
    - addNotNullConstraint:
        columnDataType:  varchar(40)
        columnName:      sha1Sum
        tableName:       repositorydocument
    - addUniqueConstraint:
        columnNames:     path, originalFilename
        constraintName:  UK_iubmgqa5xckodr6fbg6vnne0d
        tableName:       repositorydocument
    rollback:
    - dropUniqueConstraint:
        tableName:       repositorydocument
        constraintName:  UK_iubmgqa5xckodr6fbg6vnne0d
    - dropNotNullConstraint:
        tableName:       repositorydocument
        columnName:      sha1Sum
    - dropNotNullConstraint:
        tableName:       repositorydocument
        columnName:      md5Sum
    - dropColumn:
        tableName:       repositorydocument
        columnName:      active
    - dropColumn:
        tableName:       repositorydocument
        columnName:      size
    - dropColumn:
        tableName:       repositorydocument
        columnName:      lastModifiedBy
    - dropColumn:
        tableName:       repositorydocument
        columnName:      createdBy

- changeSet:
    id:                  1506155384557-2
    author:              mobreza (generated)
    changes:
    - addColumn:
        columns:
        - column:
            constraints:
              nullable:  false
            name:        active
            type:        BIT(1)
        - column:
            constraints:
              nullable:  false
            name:        size
            type:        INT(10)
        - column:
            name:        lastModifiedBy
            type:        BIGINT(19)
        - column:
            name:        createdBy
            type:        BIGINT(19)
        tableName:       repositoryfile
    - addNotNullConstraint:
        columnDataType:  varchar(32)
        columnName:      md5Sum
        tableName:       repositoryfile
    - addNotNullConstraint:
        columnDataType:  varchar(40)
        columnName:      sha1Sum
        tableName:       repositoryfile
    - addUniqueConstraint:
        columnNames:     path, originalFilename
        constraintName:  UK_27590ja5w3amn2yj2dryogm6n
        tableName:       repositoryfile
    rollback:
    - dropUniqueConstraint:
        tableName:       repositoryfile
        constraintName:  UK_27590ja5w3amn2yj2dryogm6n
    - dropNotNullConstraint:
        tableName:       repositoryfile
        columnName:      sha1Sum
    - dropNotNullConstraint:
        tableName:       repositoryfile
        columnName:      md5Sum
    - dropColumn:
        tableName:       repositoryfile
        columnName:      active
    - dropColumn:
        tableName:       repositoryfile
        columnName:      size
    - dropColumn:
        tableName:       repositoryfile
        columnName:      lastModifiedBy
    - dropColumn:
        tableName:       repositoryfile
        columnName:      createdBy


- changeSet:
    id:                  1506155384557-3
    author:              mobreza (generated)
    changes:
    - addColumn:
        columns:
        - column:
            constraints:
              nullable:  false
            name:        active
            type:        BIT(1)
        - column:
            name:        createdDate
            type:        DATETIME(19)
        - column:
            name:        createdBy
            type:        BIGINT(19)
        - column:
            name:        lastModifiedDate
            type:        DATETIME(19)
        - column:
            name:        lastModifiedBy
            type:        BIGINT(19)
        tableName:       repositorygallery
    rollback:
    - dropColumn:
        tableName:       repositorygallery
        columnName:      active
    - dropColumn:
        tableName:       repositorygallery
        columnName:      createdDate
    - dropColumn:
        tableName:       repositorygallery
        columnName:      createdBy
    - dropColumn:
        tableName:       repositorygallery
        columnName:      lastModifiedDate
    - dropColumn:
        tableName:       repositorygallery
        columnName:      lastModifiedBy

- changeSet:
    id:                  1506155384557-4
    author:              mobreza (generated)
    changes:
    - addColumn:
        columns:
        - column:
            constraints:
              nullable:  false
            name:        active
            type:        BIT(1)
        - column:
            constraints:
              nullable:  false
            name:        size
            type:        INT(10)
        - column:
            name:        lastModifiedBy
            type:        BIGINT(19)
        - column:
            name:        createdBy
            type:        BIGINT(19)
        tableName:       repositoryimage
    - addNotNullConstraint:
        columnDataType:  varchar(32)
        columnName:      md5Sum
        tableName:       repositoryimage
    - addNotNullConstraint:
        columnDataType:  varchar(40)
        columnName:      sha1Sum
        tableName:       repositoryimage
    - addUniqueConstraint:
        columnNames:     path, originalFilename
        constraintName:  UK_88rxxsqrm09geyh5go9ert6qe
        tableName:       repositoryimage
    rollback:
    - dropUniqueConstraint:
        tableName:       repositoryimage
        constraintName:  UK_88rxxsqrm09geyh5go9ert6qe
    - dropNotNullConstraint:
        tableName:       repositoryimage
        columnName:      sha1Sum
    - dropNotNullConstraint:
        tableName:       repositoryimage
        columnName:      md5Sum
    - dropColumn:
        tableName:       repositoryimage
        columnName:      active
    - dropColumn:
        tableName:       repositoryimage
        columnName:      size
    - dropColumn:
        tableName:       repositoryimage
        columnName:      lastModifiedBy
    - dropColumn:
        tableName:       repositoryimage
        columnName:      createdBy
Matija Obreza's avatar
Matija Obreza committed
448
449
450
451
452

- changeSet:
    id:                  1506155384557-5
    author:              mobreza (generated)
    changes:
Matija Obreza's avatar
Matija Obreza committed
453
454
455
    - dropForeignKeyConstraint:
        baseTableName:   repositorygalleryimage
        constraintName:  FK_rl4ttk3kctjy2nedwwlh8os3p
Matija Obreza's avatar
Matija Obreza committed
456
    - addAutoIncrement:
Matija Obreza's avatar
Matija Obreza committed
457
458
459
460
461
462
463
464
465
        tableName:       repositorygallery
        columnName:      id
        columnDataType:  BIGINT(20)
    - addForeignKeyConstraint:
        constraintName:  FK_rl4ttk3kctjy2nedwwlh8os3p
        baseTableName:   repositorygalleryimage
        baseColumnNames: galleryId
        referencedTableName: repositorygallery
        referencedColumnNames: id
Matija Obreza's avatar
Matija Obreza committed
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645


# OAuth from app-blocks-1.3-SNAPSHOT

- changeSet:
    id:                                1506594404000-2
    author:                            matijaobreza (generated)
    comment:                           naming strategy change for oauthclient
    changes:
    - renameColumn:
        columnDataType:                int
        newColumnName:                 accessTokenValidity
        oldColumnName:                 accessTokenValiditySeconds
        tableName:                     oauthclient
    - renameColumn:
        columnDataType:                int
        newColumnName:                 refreshTokenValidity
        oldColumnName:                 refreshTokenValiditySeconds
        tableName:                     oauthclient
    - renameColumn:
        columnDataType:                varchar(200)
        newColumnName:                 redirect
        oldColumnName:                 redirectUris
        tableName:                     oauthclient
    - renameColumn:
        columnDataType:                varchar(200)
        newColumnName:                 resource
        oldColumnName:                 resourceIds
        tableName:                     oauthclient
    - renameColumn:
        columnDataType:                varchar(200)
        newColumnName:                 scope
        oldColumnName:                 scope
        tableName:                     oauthclient
    - addColumn:
        tableName:                     oauthclient
        columns:
        - column:
            name:                      grants
            type:                      varchar(200)
        - column:
            name:                      autoApprove
            type:                      bit
            constraints:
              nullable:                false
        - column:
            name:                      autoApproveScope
            type:                      varchar(200)
    - dropColumn:
        tableName:                     oauthclient
        columnName:                    additional_information


- changeSet:
    id:                                application-blocks-security-1506594404000-2
    author:                            matijaobreza
    comment:                           Create 'oauthclientrole'
    changes:
    - createTable:
        tableName:                     oauthclientrole
        remarks:                       OAuth Client role list
        columns:
        - column:
            name:                      clientId
            type:                      bigint
            constraints:
              nullable:                false
        - column:
            name:                      oauthclientrole
            type:                      varchar(200)
            constraints:
              nullable:                false
    - addForeignKeyConstraint:
        constraintName:  FK_m2da63y1tfs7mmuv9rht8udt7
        baseTableName:   oauthclientrole
        baseColumnNames: clientId
        referencedTableName: oauthclient
        referencedColumnNames: id
        onDelete: CASCADE
        onUpdate: CASCADE


- changeSet:
    id:                 1507131481000-6
    author:             mobreza
    changes:
    - dropColumn:
        columnName:     grants
        tableName:      oauthclient
    - dropColumn:
        columnName:     authorities
        tableName:      oauthclient
    - renameColumn:
        columnDataType: varchar(200)
        newColumnName:  grants
        oldColumnName:  authorizedGrantTypes
        tableName:      oauthclient
    - sql:
        comment:        Migrate oauthclient , separator to ;
        sql:            update oauthclient set scope = replace(scope, ',', ';'), grants = replace(grants, ',', ';'), redirect = replace(redirect, ',', ';');
    - sql:
        comment:        Create oauthclientrole entries
        sql:            insert into oauthclientrole select id, 'USER' from oauthclient;

- changeSet:
    id:                 1507131481000-7
    author:             mobreza
    changes:
    - sql:
        comment:        Create oauthclientrole entries
        sql:            update oauthclientrole set oauthclientrole='CLIENT' where oauthclientrole='USER';


- changeSet:
    id: 1506605582245-23
    author: auto-generated
    changes:
    - dropTable:
        cascadeConstraints:            true
        tableName:                     oauthaccesstoken
    - createTable:
        columns:
        - column:
            constraints:
              nullable: false
            name: tokenId
            type: VARCHAR(100)
        - column:
            name: authentication
            type: LONGBLOB
        - column:
            name: authenticationId
            type: VARCHAR(100)
        - column:
            name: clientId
            type: VARCHAR(100)
        - column:
            name: refreshToken
            type: VARCHAR(100)
        - column:
            name: token
            type: LONGBLOB
        - column:
            name: username
            type: VARCHAR(100)
        tableName: oauthaccesstoken
    - addPrimaryKey:
        columnNames: tokenId
        constraintName: PRIMARY
        tableName: oauthaccesstoken
    - addUniqueConstraint:
        columnNames: authenticationId
        constraintName: UK_mk5dwyhm8t56m9ood899ec3hx
        tableName: oauthaccesstoken

- changeSet:
    id: 1506605582245-26
    author: auto-generated
    changes:
    - dropTable:
        cascadeConstraints:            true
        tableName:                     oauthrefreshtoken
    - createTable:
        columns:
        - column:
            constraints:
              nullable: false
            name: tokenId
            type: VARCHAR(100)
        - column:
            name: authentication
            type: LONGBLOB
        - column:
            name: token
            type: LONGBLOB
        tableName: oauthrefreshtoken
    - addPrimaryKey:
        columnNames: tokenId
        constraintName: PRIMARY
        tableName: oauthrefreshtoken
Matija Obreza's avatar
Matija Obreza committed
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682


- changeSet:
    id:                                application-blocks-security-1507137884-1
    author:                            matijaobreza
    comment:                           Add refreshToken#clientId
    changes:
    - addColumn:
        tableName:                     oauthrefreshtoken
        columns:
        - column:
            name:                      clientId
            type:                      varchar(100)
            constraints:
              nullable:                false


- changeSet:
    id:                                application-blocks-security-1507137884-2
    author:                            matijaobreza
    comment:                           Extend OAuth Tokens
    changes:
    - addColumn:
        tableName:                     oauthaccesstoken
        columns:
        - column:
            name:                      expiration
            type:                      datetime
    - addColumn:
        tableName:                     oauthrefreshtoken
        columns:
        - column:
            name:                      expiration
            type:                      datetime
        - column:
            name:                      username
            type:                      varchar(100)
683
684
685
686
687
688
689
690
691
692
693
694

- changeSet:
    id:                   1506155384557-6
    author:               a.lugovskiy (generated)
    changes:
    - addColumn:
        tableName:        article
        columns:
        - column:
            name:         template
            type:         boolean
            defaultValue: false
Matija Obreza's avatar
Matija Obreza committed
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827


- changeSet:
    id:                 1508141056000-1
    author:             mobreza
    comment:            mysql doesn't really like the float type
    changes:
    - renameColumn:
        columnDataType: double
        newColumnName:  seqNo
        oldColumnName:  seqNo
        tableName:      accession
    - renameColumn:
        columnDataType: double
        newColumnName:  seqNo
        oldColumnName:  seqNo
        tableName:      accessionhistoric

- changeSet:
    id:                 1508141056000-2
    author:             mobreza
    comment:            AccessionData extends VersionedModel (adds active)
    changes:
    - addColumn:
        tableName:        accession
        columns:
        - column:
            constraints:
              nullable: false
            defaultValue: true
            name: active
            type: BIT(1)
    - addColumn:
        tableName:        accessionhistoric
        columns:
        - column:
            constraints:
              nullable: false
            defaultValue: true
            name: active
            type: BIT(1)

- changeSet:
    id:                        1508309640296-1
    author:                    mobreza
    comment:                   Add auditlog table
    changes:
    - createTable:
        columns:
        - column:
            autoIncrement:     true
            constraints:
              primaryKey:      true
            name:              id
            type:              BIGINT
        - column:
            constraints:
              nullable:        false
            name:              action
            type:              VARCHAR(10)
        - column:
            name:              createdBy
            type:              BIGINT
        - column:
            name:              entityId
            type:              BIGINT
        - column:
            constraints:
              nullable:        false
            name:              logdate
            type:              datetime(6)
        - column:
            name:              newState
            type:              LONGTEXT
        - column:
            name:              previousState
            type:              LONGTEXT
        - column:
            constraints:
              nullable:        false
            name:              prop
            type:              VARCHAR(50)
        - column:
            constraints:
              nullable:        false
            name:              classPk
            type:              BIGINT
        - column:
            name:              entityClassPk
            type:              BIGINT
        tableName:             auditlog
    - createIndex:
        columns:
        - column:
            name:              classPk
        indexName:             FK_ebwh7n4mlnm1e8ty78h6n279x
        tableName:             auditlog
    - createIndex:
        columns:
        - column:
            name:              entityClassPk
        indexName:             FK_p30btngbfm13fwebfkmklu4wn
        tableName:             auditlog
    - createIndex:
        columns:
        - column:
            name:              entityId
        - column:
            name:              classPk
        - column:
            name:              prop
        indexName:             UK_4jxfygboql2y3pd68nmudrgw
        tableName:             auditlog
    - addForeignKeyConstraint:
        baseColumnNames:       classPk
        baseTableName:         auditlog
        constraintName:        FK_ebwh7n4mlnm1e8ty78h6n279x
        deferrable:            false
        initiallyDeferred:     false
        onDelete:              NO ACTION
        onUpdate:              NO ACTION
        referencedColumnNames: id
        referencedTableName:   classpk
    - addForeignKeyConstraint:
        baseColumnNames:       entityClassPk
        baseTableName:         auditlog
        constraintName:        FK_p30btngbfm13fwebfkmklu4wn
        deferrable:            false
        initiallyDeferred:     false
        onDelete:              NO ACTION
        onUpdate:              NO ACTION
        referencedColumnNames: id
        referencedTableName:   classpk
Maxym Borodenko's avatar
Maxym Borodenko committed
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860


- changeSet:
    id:          1508316829948-1
    author:      m.borodenko
    changes:
    - sql:
        comment: if article#slug=='smtp.email-new-password' update to article#slug='smtp-email-new-password'
        sql:     update article set slug = 'smtp-email-new-password' where slug = 'smtp.email-new-password';
    - sql:
        comment: if article#slug=='smtp.email-password' update to article#slug='smtp-email-password'
        sql:     update article set slug = 'smtp-email-password' where slug = 'smtp.email-password';
    - sql:
        comment: if article#slug=='smtp.email-verification' update to article#slug='smtp-email-verification'
        sql:     update article set slug = 'smtp-email-verification' where slug = 'smtp.email-verification';
    - sql:
        comment: if article#slug=='smtp.material-request' update to article#slug='smtp-material-request'
        sql:     update article set slug = 'smtp-material-request' where slug = 'smtp.material-request';
    - sql:
        comment: if article#slug=='smtp.material-confirm-no-pid' update to article#slug='smtp-material-confirm-no-pid'
        sql:     update article set slug = 'smtp-material-confirm-no-pid' where slug = 'smtp.material-confirm-no-pid';
    - sql:
        comment: if article#slug=='smtp.material-confirm' update to article#slug='smtp-material-confirm'
        sql:     update article set slug = 'smtp-material-confirm' where slug = 'smtp.material-confirm';
    - sql:
        comment: if article#slug=='user.password-reset' update to article#slug='user-password-reset'
        sql:     update article set slug = 'user-password-reset' where slug = 'user.password-reset';
    - sql:
        comment: if article#slug=='user.password-reset-email-sent' update to article#slug='user-password-reset-email-sent'
        sql:     update article set slug = 'user-password-reset-email-sent' where slug = 'user.password-reset-email-sent';
    - sql:
        comment: if article#slug=='user.reset-password-instructions' update to article#slug='user-reset-password-instructions'
        sql:     update article set slug = 'user-reset-password-instructions' where slug = 'user.reset-password-instructions';
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137


# User and OAuthClient extend AclSid
- changeSet:
    id:                        1509390480000-1
    author:                    matijaobreza
    comment:                   Migrate ACL to app-blocks-1.3-SNAPSHOT
    changes:
    - dropForeignKeyConstraint:
        baseTableName:         acl_entry
        constraintName:        FK_fhuoesmjef3mrv0gpja4shvcr
    - dropForeignKeyConstraint:
        baseTableName:         acl_entry
        constraintName:        FK_i6xyfccd4y3wlwhgwpo4a9rm1
    - dropForeignKeyConstraint:
        baseTableName:         acl_object_identity
        constraintName:        FK_nxv5we2ion9fwedbkge7syoc3
    - dropUniqueConstraint:
        tableName:             acl_entry
        constraintName:        UK_gh5egfpe4gaqokya6s0567b0l
    - renameTable:
        oldTableName:          acl_sid
        newTableName:          acl_sid_backup
    - renameTable:
        oldTableName:          acl_entry
        newTableName:          acl_entry_backup
    - createTable:
        columns:
        - column:
            constraints:
              nullable:        true
            name:              type
            type:              INT
        - column:
            autoIncrement:     true
            constraints:
              primaryKey:      true
            name:              id
            type:              BIGINT
        - column:
            constraints:
              nullable:        false
            name:              active
            type:              BIT(1)
            defaultValue:      true
        - column:
            constraints:
              nullable:        false
            name:              version
            type:              INT
        - column:
            name:              createdBy
            type:              BIGINT
        - column:
            name:              createdDate
            type:              datetime(6)
        - column:
            name:              lastModifiedBy
            type:              BIGINT
        - column:
            name:              lastModifiedDate
            type:              datetime(6)
        - column:
            constraints:
              nullable:        false
            name:              principal
            type:              BIT(1)
        - column:
            constraints:
              nullable:        false
            name:              sid
            type:              VARCHAR(100)
        tableName:             acl_sid
    - createTable:
        columns:
        - column:
            autoIncrement:     true
            constraints:
              primaryKey:      true
            name:              id
            type:              BIGINT
        - column:
            constraints:
              nullable:        false
            name:              ace_order
            type:              BIGINT
        - column:
            constraints:
              nullable:        false
            name:              audit_failure
            type:              BIT(1)
        - column:
            constraints:
              nullable:        false
            name:              audit_success
            type:              BIT(1)
        - column:
            constraints:
              nullable:        false
            name:              granting
            type:              BIT(1)
        - column:
            constraints:
              nullable:        false
            name:              mask
            type:              BIGINT
        - column:
            constraints:
              nullable:        false
            name:              acl_object_identity
            type:              BIGINT
        - column:
            constraints:
              nullable:        false
            name:              sid
            type:              BIGINT
        tableName:             acl_entry
    - addUniqueConstraint:
        columnNames:           acl_object_identity, ace_order
        constraintName:        UK_gh5egfpe4gaqokya6s0567b0l
        tableName:             acl_entry
    # Migrate User data to AclSid
    - sql:
        comment:               Migrate all users with their existing IDs to acl_sid
        sql:                   >-
          insert into acl_sid
            (type, id, active, version, createdBy, createdDate, lastModifiedBy,
             lastModifiedDate, principal, sid)
          select
            1, id, active, version, createdBy, createdDate, lastModifiedBy,
            lastModifiedDate, true, uuid
          from user;
    - addForeignKeyConstraint:
        baseColumnNames:       id
        baseTableName:         user
        constraintName:        FK_8qtpnv06elxuryeuv1ac4ximm
        deferrable:            false
        initiallyDeferred:     false
        onDelete:              NO ACTION
        onUpdate:              NO ACTION
        referencedColumnNames: id
        referencedTableName:   acl_sid
    - dropColumn:
        tableName:             user
        columnName:            active
    - dropColumn:
        tableName:             user
        columnName:            version
    - dropColumn:
        tableName:             user
        columnName:            createdBy
    - dropColumn:
        tableName:             user
        columnName:            createdDate
    - dropColumn:
        tableName:             user
        columnName:            lastModifiedBy
    - dropColumn:
        tableName:             user
        columnName:            lastModifiedDate
    # Migrate OAuthClient data to AclSid
    - sql:
        comment:               Migrate OAuthClient to AclSid, they get new IDs, but we can find them with clientId as acl_sid.sid
        sql:                   >-
          insert into acl_sid
            (type, active, version, createdBy, createdDate, lastModifiedBy,
            lastModifiedDate, principal, sid)
          select
            2, active, version, createdBy, createdDate, lastModifiedBy,
            lastModifiedDate, true, clientId
          from oauthclient;
    - sql:
        comment:               Update OAuthClient#id values to their new IDs as per acl_sid
        sql:                   >-
          update oauthclient oa
            join acl_sid sid on sid.sid=oa.clientId
          set oa.id=sid.id
    - addForeignKeyConstraint:
        baseColumnNames:       id
        baseTableName:         oauthclient
        constraintName:        FK_j9t6kj0254t7knyn57orqyaxk
        deferrable:            false
        initiallyDeferred:     false
        onDelete:              NO ACTION
        onUpdate:              NO ACTION
        referencedColumnNames: id
        referencedTableName:   acl_sid
    - dropColumn:
        tableName:             oauthclient
        columnName:            active
    - dropColumn:
        tableName:             oauthclient
        columnName:            version
    - dropColumn:
        tableName:             oauthclient
        columnName:            createdBy
    - dropColumn:
        tableName:             oauthclient
        columnName:            createdDate
    - dropColumn:
        tableName:             oauthclient
        columnName:            lastModifiedBy
    - dropColumn:
        tableName:             oauthclient
        columnName:            lastModifiedDate

    # Migrate acl_object_identity#owner_sid because these have changed
    - sql:
        comment:               Migrate acl_object_identity#owner_sid because these have changed
        sql:                   >-
          update acl_object_identity oid
            join acl_sid_backup oldsid on oldsid.id=oid.owner_sid
            join acl_sid newsid on newsid.sid=oldsid.sid
          set oid.owner_sid=newsid.id
    - addForeignKeyConstraint:
        baseColumnNames:       owner_sid
        baseTableName:         acl_object_identity
        constraintName:        FK_nxv5we2ion9fwedbkge7syoc3
        deferrable:            false
        initiallyDeferred:     false
        onDelete:              NO ACTION
        onUpdate:              NO ACTION
        referencedColumnNames: id
        referencedTableName:   acl_sid
    # Migrate acl_sid_backup data for authorities (roles) -- i.e. everything that has not moved
    - sql:
        comment: Delete invalid authority records from acl_sid_backup (users and oauthclients)
        sql: >-
          delete oldsid from acl_sid_backup oldsid
            inner join acl_sid newsid on newsid.sid=oldsid.sid
          where oldsid.principal = 0;
    - sql:
        comment: Generate new acl_sid for ROLE entries (AclSid.type==0)
        sql: >-
          insert into acl_sid
            (type, active, version, createdBy, createdDate, lastModifiedBy,
            lastModifiedDate, principal, sid)
          select
            0, 1, 0, null, now(), null,
            now(), false, sid
          from acl_sid_backup where principal = 0;
    # Migrate acl_entry data
    - sql:
        comment: Migrate acl_entry_backup data to acl_entry, using new acl_sid#id instead of the old one
        sql: >-
          insert into acl_entry
            (ace_order, audit_failure, audit_success, granting, mask, acl_object_identity, sid)
          select
            e.ace_order, e.audit_failure, e.audit_success, e.granting, e.mask, e.acl_object_identity, newsid.id
          from acl_entry_backup e
            inner join acl_sid_backup oldsid on oldsid.id=e.sid
            inner join acl_sid newsid on newsid.sid=oldsid.sid;
    - dropTable:
        tableName: acl_sid_backup
    - dropTable:
        tableName: acl_entry_backup
    # Activate FK constraints
    - addForeignKeyConstraint:
        baseColumnNames:       acl_object_identity
        baseTableName:         acl_entry
        constraintName:        FK_fhuoesmjef3mrv0gpja4shvcr
        deferrable:            false
        initiallyDeferred:     false
        onDelete:              NO ACTION
        onUpdate:              NO ACTION
        referencedColumnNames: id
        referencedTableName:   acl_object_identity
    - addForeignKeyConstraint:
        baseColumnNames:       sid
        baseTableName:         acl_entry
        constraintName:        FK_i6xyfccd4y3wlwhgwpo4a9rm1
        deferrable:            false
        initiallyDeferred:     false
        onDelete:              NO ACTION
        onUpdate:              NO ACTION
        referencedColumnNames: id
        referencedTableName:   acl_sid
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149

# Use user#email as acl_sid#sid
- changeSet:
    id:                        1513620354000-1
    author:                    matijaobreza
    comment:                   Use user#email as acl_sid#sid
    changes:
    - sql:
        comment: Inner join acl_sid with user on id and update acl_sid#sid with user#email
        sql: >-
          update acl_sid inner join user on user.id=acl_sid.id
            set acl_sid.sid = user.email;