liquibase-changeLog.yml 176 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;
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168

# DS2
- changeSet:
    id:                  1525172348000-1
    author:              Matija Obreza
    comment:             Renaming DS2 tables
    changes:
    - renameTable:
        newTableName:    ds2column
        oldTableName:    ds2descriptor
    - renameTable:
        newTableName:    ds2descriptor
        oldTableName:    descriptor
    - renameColumn:
        columnDataType:  BIGINT
        newColumnName:   dsc
        oldColumnName:   dsd
        remarks:         Dataset column
        tableName:       ds2value
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181

# Upgrade to appliation-blocks:1.4-SNAPSHOT
- changeSet:
    id:            1526423063000-1
    author:        mobreza
    comment:       Add lastLogin to User
    changes:
    - addColumn:
        columns:
        - column:
            name:  lastLogin
            type:  datetime(6)
        tableName: user
Matija Obreza's avatar
Matija Obreza committed
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227

- changeSet:
    id:      1530443149000-2
    author:  mobreza
    comment: Replace blanks with null and delete empty records
    changes:
    - sql:
        sql: update accession set acceUrl = null where acceUrl = '';
    - sql:
        sql: update accession set acqDate = null where acqDate = '';
    - sql:
        sql: update accessionalias set usedBy = null where usedBy = '';
    - sql:
        sql: delete from accessionalias where name = '' and (usedBy is null or instCode is null);
    - sql:
        sql: update accessionbreeding set breederCode = NULL where breederCode = '';
    - sql:
        sql: update accessionbreeding set pedigree = NULL where pedigree = '';
    - sql:
        sql: delete from accessionbreeding where pedigree is null and breederCode is null;
    - sql:
        sql: update accessioncollect set collDate = null where collDate = '';
    - sql:
        sql: update accessioncollect set collSite = null where collSite = '';
    - sql:
        sql: update accessioncollect set collCode = null where collCode = '';
    - sql:
        sql: update accessioncollect set collNumb = null where collNumb = '';
    - sql:
        sql: update accessioncollect set collMissId = null where collMissId = '';
    - sql:
        sql: update accessioncollect set collName = null where collName = '';
    - sql:
        sql: update accessioncollect set collInstAddress = null where collInstAddress = '';
    - sql:
        sql: delete from accessioncollect where collDate = null and collSite = null and collCode = null and collNumb = null and collMissId = null and collName = null and collInstAddress = null and collSrc = null;
    - sql:
        sql: update accessionexchange set acceNumb = null where acceNumb = '';
    - sql:
        sql: update accessionexchange set donorInst = null where donorInst = '';
    - sql:
        sql: update accessionexchange set donorName = null where donorName = '';
    - sql:
        sql: delete from accessionexchange where acceNumb is null and donorInst is null and donorName is null;
    - sql:
        sql: delete from auditlog where classPk = (select id from classpk where classname='org.genesys2.server.model.genesys.PDCI');
Matija Obreza's avatar
Matija Obreza committed
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294


#
# Upgrade Genesys model: relationships flips
#
- changeSet:
    id: 1531216028000-1
    author: mobreza (generated)
    changes:
    - renameTable:
        newTableName:    accession_alias
        oldTableName:    accessionalias
    - renameTable:
        newTableName:    accession_collect
        oldTableName:    accessioncollect
    - renameTable:
        newTableName:    accession_geo
        oldTableName:    accessiongeo
    - renameTable:
        newTableName:    accession_historic
        oldTableName:    accessionhistoric
    - renameTable:
        newTableName:    accession_list
        oldTableName:    accelist
    - renameTable:
        newTableName:    accession_listitem
        oldTableName:    accelistitems
    - renameTable:
        newTableName:    accession_remark
        oldTableName:    accessionremark
    - renameTable:
        newTableName:    grin_taxonomy
        oldTableName:    GrinTaxonomy


- changeSet:
    id: 1531216028024-2
    author: mobreza (generated)
    changes:
    - createTable:
        columns:
        - column:
            constraints:
              nullable: false
            name: accessionId
            type: BIGINT
        - column:
            constraints:
              nullable: false
            name: breederCode
            type: VARCHAR(9)
        tableName: accession_breedercode
    - addPrimaryKey:
        columnNames: accessionId, breederCode
        constraintName: PRIMARY
        tableName: accession_breedercode
    - addForeignKeyConstraint:
        baseColumnNames: accessionId
        baseTableName: accession_breedercode
        constraintName: FK_i24m3cu3iutcu874affqlph62
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: id
        referencedTableName: acce

1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327

- changeSet:
    id: 1531216028024-2b
    author: mobreza (generated)
    changes:
    - createTable:
        columns:
        - column:
            constraints:
              nullable: false
            name: accessionId
            type: BIGINT
        - column:
            constraints:
              nullable: false
            name: breederName
            type: VARCHAR(250)
        tableName: accession_breedername
    - addPrimaryKey:
        columnNames: accessionId, breederName
        constraintName: PRIMARY
        tableName: accession_breedername
    - addForeignKeyConstraint:
        baseColumnNames: accessionId
        baseTableName: accession_breedername
        constraintName: FK_k4abe2rmtbjbvs1uxv1gv9vyj
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: id
        referencedTableName: acce

Matija Obreza's avatar
Matija Obreza committed
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
- changeSet:
    id: 1531216028024-4
    author: mobreza (generated)
    changes:
    - createTable:
        columns:
        - column:
            constraints:
              nullable: false
            name: collectId
            type: BIGINT
        - column:
            constraints:
              nullable: false
            name: collCode
            type: VARCHAR(128)
        tableName: accession_collect_code
    - addPrimaryKey:
        columnNames: collectId, collCode
        constraintName: PRIMARY
        tableName: accession_collect_code
    - addForeignKeyConstraint:
        baseColumnNames: collectId
        baseTableName: accession_collect_code
        constraintName: FK_p16on5ehgaa05ut41f87umkfa
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: id
        referencedTableName: accession_collect

- changeSet:
    id: 1531216028024-5
    author: mobreza (generated)
    changes:
    - createTable:
        columns:
        - column:
            constraints:
              nullable: false
            name: collectId
            type: BIGINT
        - column:
            constraints:
              nullable: false
            name: collInstAddress
            type: VARCHAR(128)
        tableName: accession_collect_instaddr
    - addPrimaryKey:
        columnNames: collectId, collInstAddress
        constraintName: PRIMARY
        tableName: accession_collect_instaddr
    - addForeignKeyConstraint:
        baseColumnNames: collectId
        baseTableName: accession_collect_instaddr
        constraintName: FK_t9qrwws135bnmm0kh8fywg5j2
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: id
        referencedTableName: accession_collect


- changeSet:
    id: 1531216028024-6
    author: mobreza (generated)
    changes:
    - createTable:
        columns:
        - column:
            constraints:
              nullable: false
            name: collectId
            type: BIGINT
        - column:
            constraints:
              nullable: false
            name: collName
1408
            type: VARCHAR(250)
Matija Obreza's avatar
Matija Obreza committed
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
        tableName: accession_collect_name
    - addPrimaryKey:
        columnNames: collectId, collName
        constraintName: PRIMARY
        tableName: accession_collect_name
    - addForeignKeyConstraint:
        baseColumnNames: collectId
        baseTableName: accession_collect_name
        constraintName: FK_g6h5uuvq16105ljx8r1jjxojr
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: id
        referencedTableName: accession_collect

- changeSet:
    id: 1531216028024-7
    author: mobreza (generated)
    changes:
    - createTable:
        columns:
        - column:
            constraints:
              nullable: false
            name: accessionId
            type: BIGINT
        - column:
            constraints:
              nullable: false
            name: duplSite
            type: VARCHAR(9)
        tableName: accession_duplsite
    - addPrimaryKey:
        columnNames: accessionId, duplSite
        constraintName: PRIMARY
        tableName: accession_duplsite
    - addForeignKeyConstraint:
        baseColumnNames: accessionId
        baseTableName: accession_duplsite
        constraintName: FK_2se3c4vyb38ci81qch7siopbu
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: id
        referencedTableName: acce

- changeSet:
    id: 1531216028024-13
    author: mobreza (generated)
    changes:
    - createTable:
        columns:
        - column:
            constraints:
              nullable: false
            name: accessionId
            type: BIGINT
        - column:
            constraints:
              nullable: false
            name: storage
            type: INT
        tableName: accession_storage
    - addPrimaryKey:
        columnNames: accessionId, storage
        constraintName: PRIMARY
        tableName: accession_storage
    - addForeignKeyConstraint:
        baseColumnNames: accessionId
        baseTableName: accession_storage
        constraintName: FK_2lk4y987jla0fka5nafkwmrbq
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: id
        referencedTableName: acce

- changeSet:
    id:            1531216028024-15
    author:        mobreza
    changes:
    - addColumn:
        tableName: accession
        columns:
        - column:
            # constraints:
            #   nullable: false
            name:  genus
            type:  VARCHAR(100)
        - column:
            name:  ancest
            type:  LONGTEXT
        - column:
            name:  donorCode
            type:  VARCHAR(9)
        - column:
            name:  donorName
            type:  VARCHAR(300)
        - column:
            name:  donorNumb
            type:  VARCHAR(200)
        - column:
            name:  names
            type:  LONGTEXT
        - column:
            name:  otherIds
            type:  LONGTEXT

- changeSet:
    id: 1531216028024-15a
    author: mobreza (generated)
    changes:
    - renameColumn:
        columnDataType:  varchar(100)
        newColumnName:   duplSiteStr
        oldColumnName:   duplSite
        remarks:         MCPD DUPLSITE as string
        tableName:       accession
    - renameColumn:
        columnDataType:  varchar(100)
        newColumnName:   storageStr
        oldColumnName:   storage
        remarks:         MCPD STORAGE as string
        tableName:       accession
    - renameColumn:
        columnDataType:  varchar(3)
        newColumnName:   origCty
        oldColumnName:   orgCty
        remarks:         MCPD storage as string
        tableName:       accession

- changeSet:
    id: 1531216028024-15b
    author: mobreza (generated)
    changes:
    - addColumn:
        tableName: accession_historic
        columns:
        - column:
            # constraints:
            #   nullable: false
            name:  genus
            type:  VARCHAR(100)
        - column:
            name:  ancest
            type:  LONGTEXT
        - column:
            name:  donorCode
            type:  VARCHAR(9)
        - column:
            name:  donorName
            type:  VARCHAR(300)
        - column:
            name:  donorNumb
            type:  VARCHAR(200)
        - column:
            name:  names
            type:  LONGTEXT
        - column:
            name:  otherIds
            type:  LONGTEXT

- changeSet:
    id: 1531216028024-15c
    author: mobreza (generated)
    changes:
    - renameColumn:
        columnDataType:  varchar(100)
        newColumnName:   duplSiteStr
        oldColumnName:   duplSite
        remarks:         MCPD DUPLSITE as string
        tableName:       accession_historic
    - renameColumn:
        columnDataType:  varchar(100)
        newColumnName:   storageStr
        oldColumnName:   storage
        remarks:         MCPD STORAGE as string
        tableName:       accession_historic
    - renameColumn:
        columnDataType:  varchar(3)
        newColumnName:   origCty
        oldColumnName:   orgCty
        remarks:         MCPD storage as string
        tableName:       accession_historic


- changeSet:
    id: 1531216028024-16
    author: mobreza (generated)
    changes:
    - addColumn:
        columns:
        - column:
            name: collId
            type: BIGINT
        - column:
            name: geoId
            type: BIGINT
        - column:
            name: pdciId
            type: BIGINT
        tableName: acce
    - addUniqueConstraint:
        columnNames: collId
        constraintName: UK_8qrr86qim9fyaevm0gmneylnw
        tableName: acce
    - addUniqueConstraint:
        columnNames: geoId
        constraintName: UK_a4cq6l63j6xie0fwv806lfyhu
        tableName: acce
    - addUniqueConstraint:
        columnNames: pdciId
        constraintName: UK_ncmba94f9sebh9h056jqhukum
        tableName: acce

- changeSet:
    id: 1531219203066-4
    author: mobreza (generated)
    changes:
    - createIndex:
        columns:
        - column:
            name: acceNumb
        indexName: IX_acceNumb
        tableName: accession

- changeSet:
    id: 1531219203066-7
    author: mobreza (generated)
    changes:
    - dropForeignKeyConstraint:
        baseTableName: accession_collect
        constraintName: FK_3xjhvjcunn2ievi36gmuvf6nk
    - dropUniqueConstraint:
        constraintName: UK_3xjhvjcunn2ievi36gmuvf6nk
        tableName: accession_collect
    - addForeignKeyConstraint:
        baseColumnNames: collId
        baseTableName: acce
        constraintName: FK_8qrr86qim9fyaevm0gmneylnw
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: id
        referencedTableName: accession_collect

- changeSet:
    id: 1531219203066-8
    author: mobreza (generated)
    changes:
    - dropForeignKeyConstraint:
        baseTableName: accession_geo
        constraintName: FK_mrtltk1iiohn7x6p6b9saxfee
    - dropUniqueConstraint:
        constraintName: UK_mrtltk1iiohn7x6p6b9saxfee
        tableName: accession_geo
    - addForeignKeyConstraint:
        baseColumnNames: geoId
        baseTableName: acce
        constraintName: FK_a4cq6l63j6xie0fwv806lfyhu
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: id
        referencedTableName: accession_geo

- changeSet:
    id: 1531219203066-9
    author: mobreza (generated)
    changes:
    - dropForeignKeyConstraint:
        baseTableName: pdci
        constraintName: FK_c3fnk9quh9lou6hd1v5hpanbw
    - dropUniqueConstraint:
        constraintName: UK_offskcy4kgtcg89hcd8w9phmh
        tableName: pdci
    - addForeignKeyConstraint:
        baseColumnNames: pdciId
        baseTableName: acce
        constraintName: FK_ncmba94f9sebh9h056jqhukum
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: id
        referencedTableName: pdci

- changeSet:
    id: 1531219203066-35
    author: mobreza (generated)
    changes:
    - modifyDataType:
        columnName: datum
        newDataType: varchar(100)
        tableName: accession_geo
    - modifyDataType:
        columnName: method
        newDataType: varchar(100)
        tableName: accession_geo
    - createIndex:
        columns:
        - column:
            name: latitude
        - column:
            name: longitude
        indexName: UK_98cgokk6e16eqowc7iemvshid
        tableName: accession_geo
    - createIndex:
        columns:
        - column:
            name: tileIndex
        indexName: UK_25vrycbl69i8q41ewm4p9m13r
        tableName: accession_geo

- changeSet:
    id: 1531219203066-43
    author: mobreza (generated)
    changes:
    - addNotNullConstraint:
        columnDataType: clob
        columnName: remark
        tableName: accession_remark
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898

- changeSet:
    id:      1531219203099-1
    author:  mobreza
    comment: Migrate data to new model
    changes:
    - sql:
        sql: >-
          drop table if exists t_collCode;
          create table if not exists t_collCode as
          select
            @num_e := 1 + LENGTH(collCode) - LENGTH(REPLACE(collCode, ';', '')) AS num_e,
            id, collCode,
            SUBSTRING_INDEX(collCode,';',1) as coll1,
            IF(@num_e > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(collCode,';',2),';',-1), null) coll2,
            IF(@num_e > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(collCode,';',3),';',-1), null) coll3,
            IF(@num_e > 3, SUBSTRING_INDEX(SUBSTRING_INDEX(collCode,';',3),';',-1), null) coll4
          from accession_collect where collCode is not null;
          insert into accession_collect_code (collectId,collCode)
            (select distinct id, coll1 from
              (select id, coll1 from t_collCode where coll1 is not null
               union all select id, coll2 from t_collCode where coll2 is not null
               union all select id, coll3 from t_collCode where coll3 is not null
               union all select id, coll4 from t_collCode where coll4 is not null) Q);
          drop table t_collCode;
    - dropColumn:
        columnName: collCode
        tableName: accession_collect

- changeSet:
    id:      1531219203099-2
    author:  mobreza
    comment: Migrate data to new model
    changes:
    - sql:
        sql: >-
          drop table if exists t_collInstAddress;
          create table if not exists t_collInstAddress as
          select
            @num_e := 1 + LENGTH(collInstAddress) - LENGTH(REPLACE(collInstAddress, ';', '')) AS num_e,
            id, collInstAddress,
            SUBSTRING_INDEX(collInstAddress,';',1) as coll1,
            IF(@num_e > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(collInstAddress,';',2),';',-1), null) coll2,
            IF(@num_e > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(collInstAddress,';',3),';',-1), null) coll3,
            IF(@num_e > 3, SUBSTRING_INDEX(SUBSTRING_INDEX(collInstAddress,';',3),';',-1), null) coll4
          from accession_collect where collInstAddress is not null;
          insert into accession_collect_instaddr (collectId,collInstAddress)
            (select distinct id, coll1 from
              (select id, coll1 from t_collInstAddress where coll1 is not null
               union all select id, coll2 from t_collInstAddress where coll2 is not null
               union all select id, coll3 from t_collInstAddress where coll3 is not null
               union all select id, coll4 from t_collInstAddress where coll4 is not null) Q);
          drop table t_collInstAddress;
    - dropColumn:
        columnName: collInstAddress
        tableName: accession_collect

- changeSet:
    id:      1531219203099-3
    author:  mobreza
    comment: Migrate data to new model
    changes:
    - sql:
        sql: >-
          drop table if exists t_collName;
          create table if not exists t_collName as
          select
            @num_e := 1 + LENGTH(collName) - LENGTH(REPLACE(collName, ';', '')) AS num_e,
            id, collName,
            SUBSTRING_INDEX(collName,';',1) as coll1,
            IF(@num_e > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(collName,';',2),';',-1), null) coll2,
            IF(@num_e > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(collName,';',3),';',-1), null) coll3,
            IF(@num_e > 3, SUBSTRING_INDEX(SUBSTRING_INDEX(collName,';',3),';',-1), null) coll4
          from accession_collect where collName is not null;
          insert into accession_collect_name (collectId,collName)
            (select distinct id, coll1 from
              (select id, coll1 from t_collName where coll1 is not null
               union all select id, coll2 from t_collName where coll2 is not null
               union all select id, coll3 from t_collName where coll3 is not null
               union all select id, coll4 from t_collName where coll4 is not null) Q);
          drop table t_collName;
    - dropColumn:
        columnName: collName
        tableName: accession_collect


- changeSet:
    id:      1531219203099-3
    author:  mobreza
    comment: Migrate data to new model
    changes:
    - sql:
        sql: >-
          drop table if exists t_collName;
          create table if not exists t_collName as
          select
            @num_e := 1 + LENGTH(collName) - LENGTH(REPLACE(collName, ';', '')) AS num_e,
            id, collName,
            SUBSTRING_INDEX(collName,';',1) as coll1,
            IF(@num_e > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(collName,';',2),';',-1), null) coll2,
            IF(@num_e > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(collName,';',3),';',-1), null) coll3,
            IF(@num_e > 3, SUBSTRING_INDEX(SUBSTRING_INDEX(collName,';',3),';',-1), null) coll4
          from accession_collect where collName is not null;
          insert into accession_collect_name (collectId,collName)
            (select distinct id, coll1 from
              (select id, coll1 from t_collName where coll1 is not null
               union all select id, coll2 from t_collName where coll2 is not null
               union all select id, coll3 from t_collName where coll3 is not null
               union all select id, coll4 from t_collName where coll4 is not null) Q);
          drop table t_collName;
    - dropColumn:
        columnName: collName
        tableName: accession_collect

- changeSet:
    id: 1531221360983-16
    author: mobreza (generated)
    changes:
    - sql:
        sql: >-
          update accessionbreeding B inner join accession A on A.id = B.accessionId set A.ancest = B.pedigree;
    - sql:
        sql: >-
          update accessionbreeding B inner join accession_historic A on A.id = B.accessionId set A.ancest = B.pedigree;

- changeSet:
    id: 1531221360983-16b
    author: mobreza (generated)
    changes:
    - sql:
        sql: >-
          drop table if exists t_breederCode;
          create table if not exists t_breederCode as
          select
            @num_e := 1 + LENGTH(breederCode) - LENGTH(REPLACE(breederCode, ';', '')) AS num_e,
            accessionId, breederCode,
            SUBSTRING_INDEX(breederCode,';',1) as coll1,
            IF(@num_e > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(breederCode,';',2),';',-1), null) coll2,
            IF(@num_e > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(breederCode,';',3),';',-1), null) coll3,
            IF(@num_e > 3, SUBSTRING_INDEX(SUBSTRING_INDEX(breederCode,';',3),';',-1), null) coll4
          from accessionbreeding where breederCode is not null;
          insert into accession_breedercode (accessionId,breederCode)
            (select distinct accessionId, coll1 from
              (select accessionId, coll1 from t_breederCode where coll1 is not null
               union all select accessionId, coll2 from t_breederCode where coll2 is not null
               union all select accessionId, coll3 from t_breederCode where coll3 is not null
               union all select accessionId, coll4 from t_breederCode where coll4 is not null) Q);
          drop table t_breederCode;
    - dropTable:
        tableName: accessionbreeding


- changeSet:
    id: 1531221360983-37
    author: mobreza (generated)
    changes:
    - sql:
        sql: >-
          update accession a inner join taxonomy2 t on t.id=a.taxonomyId2 set a.genus = t.genus;
    - sql:
        sql: >-
          update accession_historic a inner join taxonomy2 t on t.id=a.taxonomyId2 set a.genus = t.genus;

1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
# BUG: This kills mariadb when running as non-root in cluster mode
# - changeSet:
#     id: 1531221360983-37a
#     author: mobreza (generated)
#     comment: Move duplicates to accession_historic
#     changes:
#     - sql:
#         sql: >-
#           drop table if exists t_accessiondup;
#           create table t_accessiondup select min(id) minId from accession group by instituteId, genus, acceNumb having count(*) > 1;
#           insert into accession_historic (id, acceNumb, seqNo, acqDate, acqSrc, available, duplSiteStr, inSGSV, inTrust, instCode, mlsStat, origCty, sampStat, storageStr, orgCtyId, instituteId, taxonomyId2, taxGenus, historic, createdDate, lastModifiedDate, createdBy, lastModifiedBy, version, acceurl, cropName, cropId, doi, active, genus, ancest, donorCode, donorName, donorNumb, names, otherIds)
#             select id, acceNumb, seqNo, acqDate, acqSrc, available, duplSiteStr, inSGSV, inTrust, instCode, mlsStat, origCty, sampStat, storageStr, orgCtyId, instituteId, taxonomyId2, taxGenus, historic, createdDate, lastModifiedDate, createdBy, lastModifiedBy, version, acceurl, cropName, cropId, doi, active, genus, ancest, donorCode, donorName, donorNumb, names, otherIds from accession where id in (select minId from t_accessiondup);
#           delete from accession where id in (select minId from t_accessiondup);
#           drop table t_accessiondup;
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027

- changeSet:
    id:                 1531221360983-37b1
    author:             mobreza (generated)
    changes:
    - dropUniqueConstraint:
        constraintName: UK_975ha8nh9k5itsuvg4bd0853i
        tableName:      accession

- changeSet:
    id:                 1531221360983-37b2
    author:             mobreza (generated)
    changes:
    - dropUniqueConstraint:
        constraintName: UQ_accession_genus_inst
        tableName:      accession

- changeSet:
    id: 1531221360983-37c
    author: mobreza (generated)
    changes:
    - addNotNullConstraint:
        columnDataType: varchar(100)
        columnName: genus
        tableName: accession
    - addUniqueConstraint:
        columnNames: instituteId, genus, acceNumb
        constraintName: UQ_accession_genus_inst
        tableName: accession
    - addNotNullConstraint:
        columnDataType: varchar(100)
        columnName: genus
        tableName: accession_historic
    - dropColumn:
        columnName: taxGenus
        tableName: accession
    - dropColumn:
        columnName: taxGenus
        tableName: accession_historic


- changeSet:
    id: 1531221360983-36
    author: mobreza (generated)
    changes:
    - dropIndex:
        indexName: I_accessionalias_name
        tableName: accession_alias
    - dropColumn:
        columnName: instCode
        tableName: accession_alias

- changeSet:
    id: 1531221360983-29
    author: mobreza (generated)
    changes:
    - sql:
        sql: >-
          update accession_collect C inner join acce A on A.id = C.accessionId set A.collId = C.id;
    - dropColumn:
        columnName: accessionId
        tableName: accession_collect


- changeSet:
    id: 1531221360983-30
    author: mobreza (generated)
    changes:
    - sql:
        sql: >-
          update accession_geo G inner join acce A on A.id = G.accessionId set A.geoId = G.id;
    - dropColumn:
        columnName: accessionId
        tableName: accession_geo

- changeSet:
    id: 1531221360983-31
    author: mobreza (generated)
    changes:
    - sql:
        sql: >-
          update pdci P inner join acce A on A.id = P.accessionId set A.pdciId = P.id;
    - dropColumn:
        columnName: accessionId
        tableName: pdci

- changeSet:
    id: 1531221360983-116
    author: mobreza (generated)
    changes:
    - modifyDataType:
        columnName: uniqueAcceNumbs
        newDataType: boolean
        tableName: faoinstitute
    - addDefaultValue:
        columnDataType: boolean
        columnName: uniqueAcceNumbs
        defaultValueBoolean: false
        tableName: faoinstitute
    - modifyDataType:
        columnName: allowMaterialRequests
        newDataType: boolean
        tableName: faoinstitute
    - addDefaultValue:
        columnDataType: boolean
        columnName: allowMaterialRequests
        defaultValueBoolean: false
        tableName: faoinstitute

- changeSet:
    id: 1531221360983-18
    author: mobreza (generated)
    changes:
    - sql:
        sql: >-
2028
2029
          insert into accession_storage (accessionId, storage) select accessionId, storage from accessionstorage inner join acce on acce.id=accessionstorage.accessionId;
          insert into accession_storage (accessionId, storage) select accessionId, storage from accessionstorageh inner join acce on acce.id=accessionstorageh.accessionId;
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
    - dropTable:
        tableName: accessionstorage
    - dropTable:
        tableName: accessionstorageh

- changeSet:
    id: 1531221360983-17
    author: mobreza (generated)
    changes:
    - sql:
        sql: >-
          update accessionexchange E inner join accession A on A.id=E.accessionId set A.donorCode=E.donorInst, A.donorName=E.donorName, A.donorNumb=E.acceNumb;
    - sql:
        sql: >-
          update accessionexchange E inner join accession_historic A on A.id=E.accessionId set A.donorCode=E.donorInst, A.donorName=E.donorName, A.donorNumb=E.acceNumb;
    - dropTable:
        tableName: accessionexchange


- changeSet:
    id: 1531221360981-1
    author: mobreza (generated)
    changes:
    - sql:
        sql: >-
          update accession set duplSiteStr = null where duplSiteStr like '%:%';
    - sql:
        sql: >-
          drop table if exists t_duplsite;
          create table if not exists t_duplsite as
          select
            @num_e := 1 + LENGTH(duplSiteStr) - LENGTH(REPLACE(duplSiteStr, ';', '')) AS num_e,
            id, duplSiteStr,
            SUBSTRING_INDEX(duplSiteStr,';',1) as coll1,
            IF(@num_e > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(duplSiteStr,';',2),';',-1), null) coll2,
            IF(@num_e > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(duplSiteStr,';',3),';',-1), null) coll3,
            IF(@num_e > 3, SUBSTRING_INDEX(SUBSTRING_INDEX(duplSiteStr,';',3),';',-1), null) coll4
          from accession where duplSiteStr is not null;
          insert into accession_duplsite (accessionId, duplSite)
            (select distinct id, coll1 from
              (select id, coll1 from t_duplsite where coll1 is not null
               union all select id, coll2 from t_duplsite where coll2 is not null
               union all select id, coll3 from t_duplsite where coll3 is not null
               union all select id, coll4 from t_duplsite where coll4 is not null) Q);
          drop table t_duplsite;


- changeSet:
    id: 1531221360981-2
    author: mobreza (generated)
    changes:
    - sql:
        sql: >-
          update accession_historic set duplSiteStr = null where duplSiteStr like '%:%';
    - sql:
        sql: >-
          drop table if exists t_duplsite;
          create table if not exists t_duplsite as
          select
            @num_e := 1 + LENGTH(duplSiteStr) - LENGTH(REPLACE(duplSiteStr, ';', '')) AS num_e,
            id, duplSiteStr,
            SUBSTRING_INDEX(duplSiteStr,';',1) as coll1,
            IF(@num_e > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(duplSiteStr,';',2),';',-1), null) coll2,
            IF(@num_e > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(duplSiteStr,';',3),';',-1), null) coll3,
            IF(@num_e > 3, SUBSTRING_INDEX(SUBSTRING_INDEX(duplSiteStr,';',3),';',-1), null) coll4
          from accession_historic where duplSiteStr is not null;
          insert into accession_duplsite (accessionId, duplSite)
            (select distinct id, coll1 from
              (select id, coll1 from t_duplsite where coll1 is not null
               union all select id, coll2 from t_duplsite where coll2 is not null
               union all select id, coll3 from t_duplsite where coll3 is not null
               union all select id, coll4 from t_duplsite where coll4 is not null) Q);
          drop table t_duplsite;

- changeSet:
    id:            1531483642000-1
    author:        mobreza
    changes:
    - createIndex:
        columns:
        - column:
            name:  instituteId
        - column:
            name:  seqNo
        indexName: IX_inst_seq
        tableName: accession
    - createIndex:
        columns:
        - column:
            name:  orgCtyId
        - column:
            name:  seqNo
        indexName: IX_cty_seq
        tableName: accession
    - createIndex:
        columns:
        - column:
            name:  taxonomyId2
        - column:
            name:  seqNo
        indexName: IX_taxa_seq
        tableName: accession

- changeSet:
    id:      1531483642000-2
    author:  mobreza
    comment: Remove trailing whitespace in taxonomy2 table
    changes:
    - sql:
        sql: >-
          update taxonomy2 set genus=trim(genus) where genus like '% ';
          update taxonomy2 set species=trim(species) where species like '% ';
          update taxonomy2 set subtaxa=trim(subtaxa) where subtaxa  like '% ';

- changeSet:
    id:      1531483642000-3
    author:  mobreza
    comment: Remove blanks in accession table
    changes:
    - sql:
        sql: >-
          update accession set acqSrc = null where acqSrc = '';

- changeSet:
    id:      1531483642000-4
    author:  mobreza
    comment: Remove blanks in accession table
    changes:
    - sql:
        sql: >-
          update accession set duplSiteStr = null where duplSiteStr = '';
          update accession set storageStr = null where storageStr = '';
Matija Obreza's avatar
Matija Obreza committed
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177

- changeSet:
    id:                        1517579783779-1
    author:                    mborodenko
    changes:
    - createTable:
        columns:
        - column:
            autoIncrement:     true
            constraints:
              primaryKey:      true
            name:              id
            type:              BIGINT
        - column:
            constraints:
              nullable:        false
Matija Obreza's avatar
Matija Obreza committed
2178
2179
            name:              uuid
            type:              BINARY(16)
Matija Obreza's avatar
Matija Obreza committed
2180
2181
2182
2183
2184
2185
2186
2187
        - column:
            constraints:
              nullable:        false
            name:              version
            type:              INT
        - column:
            constraints:
              nullable:        false
Matija Obreza's avatar
Matija Obreza committed
2188
2189
2190
2191
2192
            name:              active
            type:              boolean
        - column:
            name:              dateCreated
            type:              VARCHAR(100)
Matija Obreza's avatar
Matija Obreza committed
2193
2194
        - column:
            name:              description
Matija Obreza's avatar
Matija Obreza committed
2195
            type:              LONGTEXT
Matija Obreza's avatar
Matija Obreza committed
2196
2197
        - column:
            name:              published
Matija Obreza's avatar
Matija Obreza committed
2198
2199
2200
2201
            type:              boolean
        - column:
            name:              publisher
            type:              VARCHAR(250)
Matija Obreza's avatar
Matija Obreza committed
2202
2203
        - column:
            name:              rights
Matija Obreza's avatar
Matija Obreza committed
2204
            type:              VARCHAR(100)
Matija Obreza's avatar
Matija Obreza committed
2205
        - column:
Matija Obreza's avatar
Matija Obreza committed
2206
2207
            constraints:
              nullable:        false
Matija Obreza's avatar
Matija Obreza committed
2208
            name:              title
Matija Obreza's avatar
Matija Obreza committed
2209
            type:              VARCHAR(250)
Matija Obreza's avatar
Matija Obreza committed
2210
        - column:
Matija Obreza's avatar
Matija Obreza committed
2211
2212
2213
2214
            constraints:
              nullable:        false
            name:              wiews_code
            type:              VARCHAR(8)
Matija Obreza's avatar
Matija Obreza committed
2215
        - column:
Matija Obreza's avatar
Matija Obreza committed
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
            constraints:
              nullable:        false
            name:              institute_id
            type:              BIGINT
        - column:
            constraints:
              nullable:        false
            name:              accession_count
            type:              INT
        - column:
            name:              createdBy
            type:              BIGINT
        - column:
            name:              createdDate
            type:              datetime
        - column:
            name:              lastModifiedBy
            type:              BIGINT
        - column:
            name:              lastModifiedDate
            type:              datetime
Matija Obreza's avatar
Matija Obreza committed
2237
2238
2239
        tableName:             subset
    - addUniqueConstraint:
        columnNames:           uuid
Matija Obreza's avatar
Matija Obreza committed
2240
        constraintName:        UK_7dqvpc7p1sj2gd5yqpp2esrim
Matija Obreza's avatar
Matija Obreza committed
2241
        tableName:             subset
Matija Obreza's avatar
Matija Obreza committed
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
    - addForeignKeyConstraint:
        baseColumnNames:       institute_id
        baseTableName:         subset
        constraintName:        FK_i4bhde33tt9c8u4uuikwdtu2u
        deferrable:            false
        initiallyDeferred:     false
        onDelete:              NO ACTION
        onUpdate:              NO ACTION
        referencedColumnNames: id
        referencedTableName:   faoinstitute
    - createIndex:
        columns:
        - column:
            name:              institute_id
        indexName:             FK_i4bhde33tt9c8u4uuikwdtu2u
        tableName:             subset

Matija Obreza's avatar
Matija Obreza committed
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268

- changeSet:
    id:                        1517579783779-2
    author:                    mborodenko
    changes:
    - createTable:
        columns:
        - column:
            constraints:
              nullable:        false
Matija Obreza's avatar
Matija Obreza committed
2269
            name:              subset_id
Matija Obreza's avatar
Matija Obreza committed
2270
2271
2272
2273
            type:              BIGINT
        - column:
            constraints:
              nullable:        false
Matija Obreza's avatar
Matija Obreza committed
2274
            name:              acce_id
Matija Obreza's avatar
Matija Obreza committed
2275
            type:              BIGINT
Matija Obreza's avatar
Matija Obreza committed
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
        tableName:             subset_accession
    - createIndex:
        columns:
        - column:
            name:              subset_id
        indexName:             FK_deitjtix5v97n7jrh6vmbr9qc
        tableName:             subset_accession
    - createIndex:
        columns:
        - column:
            name:              acce_id
        indexName:             FK_katykqajfv00xx2l9rds8244a
        tableName:             subset_accession
Matija Obreza's avatar
Matija Obreza committed
2289
    - addForeignKeyConstraint:
Matija Obreza's avatar
Matija Obreza committed
2290
2291
        baseColumnNames:       acce_id
        baseTableName:         subset_accession
Matija Obreza's avatar
Matija Obreza committed
2292
2293
2294
2295
2296
2297
2298
2299
        constraintName:        FK_95rt3vjsm7s4j10s28p0qgf1y
        deferrable:            false
        initiallyDeferred:     false
        onDelete:              NO ACTION
        onUpdate:              NO ACTION
        referencedColumnNames: id
        referencedTableName:   acce
    - addForeignKeyConstraint:
Matija Obreza's avatar
Matija Obreza committed
2300
2301
        baseColumnNames:       subset_id
        baseTableName:         subset_accession
Matija Obreza's avatar
Matija Obreza committed
2302
2303
2304
2305
2306
2307
2308
        constraintName:        FK_cdu46dj9nbw21wi40rky6jy93
        deferrable:            false
        initiallyDeferred:     false
        onDelete:              NO ACTION
        onUpdate:              NO ACTION
        referencedColumnNames: id
        referencedTableName:   subset
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329

- changeSet:
    id: 1531941193570-18
    author: mobreza (generated)
    comment: Changes for file-repository@1.0-SNAPSHOT
    changes:
    - renameTable:
        newTableName:    repository_document
        oldTableName:    repositorydocument
    - renameTable:
        newTableName:    repository_file
        oldTableName:    repositoryfile
    - renameTable:
        newTableName:    repository_gallery
        oldTableName:    repositorygallery
    - renameTable:
        newTableName:    repository_gallery_image
        oldTableName:    repositorygalleryimage
    - renameTable:
        newTableName:    repository_image
        oldTableName:    repositoryimage
Matija Obreza's avatar
Matija Obreza committed
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670