This repository has been archived by the owner on Jul 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 81
/
db-upgrade.xml
2583 lines (2360 loc) · 151 KB
/
db-upgrade.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
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
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
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
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
683
684
685
686
687
688
689
690
691
692
693
694
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
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
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
<project name="db-upgrade" default="upgrade" basedir=".">
<!--
This target upgrades a database schema. The parameters that it accepts are: jdbc.url = the jdbc url of the database
to upgrade jdbc.user = the user to connect to the database as jdbc.password = the database user's password
target.schema.version = the schema version to upgrade to. If this is omitted then the schema is upgraded to the
latest version. This target assumes that the taskdefs for the dbupgrade ant task have already been defined.
-->
<target name="upgrade">
<echo>
DB Upgrade:
JDBC URL: ${jdbc.url}
JDBC User: ${jdbc.user}
Update Version: ${target.schema.version}
</echo>
<dbupgrade jdbcUrl="${jdbc.url}"
jdbcUser="${jdbc.user}"
jdbcPassword="${jdbc.password}"
valueColumn="PROPERTY_VALUE"
table="RHQ_SYSTEM_CONFIG"
keyColumn="PROPERTY_KEY"
keyMatch="DB_SCHEMA_VERSION"
targetSchemaVersion="${target.schema.version}">
<schemaSpec version="2.0">
<!-- Empty initial schema to avoid install failure on default latest schema version -->
</schemaSpec>
<!-- 2.1 through 2.69 removed, no longer needed as these versions are not in use -->
<schemaSpec version="2.70">
<schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" />
<schema-addColumn table="RHQ_ALERT" column="ACK_SUBJECT" precision="100" columnType="VARCHAR2" />
</schemaSpec>
<schemaSpec version="2.70.1">
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_NAME" precision="100" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_CONFIG_ID" columnType="INTEGER" />
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="EXTRA_CONFIG_ID" columnType="INTEGER" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
ADD CONSTRAINT RHQ_AN_SENDER_CONFIG_ID_FK
FOREIGN KEY (SENDER_CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
</schema-directSQL>
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
ADD CONSTRAINT RHQ_AN_EXTRA_CONFIG_ID_FK
FOREIGN KEY (EXTRA_CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.70.2">
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" columnType="VARCHAR2" precision="100" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="RESULT_STATE" columnType="VARCHAR2" precision="20" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="MESSAGE" columnType="VARCHAR2" precision="4000" />
</schemaSpec>
<schemaSpec version="2.70.3">
<schema-directSQL ignoreError="true">
<statement desc="Dropping unique index RHQ_ALERT_IDX_ALERT">
DROP INDEX RHQ_ALERT_IDX_ALERT
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.70.4">
<!-- turn first-class notification data into configuration objects for custom alert senders -->
<schema-alterColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" nullable="TRUE" />
<schema-javaTask className="CustomAlertSenderUpgradeTask" />
<!-- the old alert notification rows won't have SENDER_NAME set, remove them -->
<schema-directSQL>
<statement desc="Removing obsolete alert notifications">
DELETE FROM RHQ_ALERT_NOTIFICATION WHERE SENDER_NAME IS NULL
</statement>
</schema-directSQL>
<!-- the old alert notification log rows won't have SENDER set, remove them -->
<schema-directSQL>
<statement desc="Removing obsolete alert notification logs">
DELETE FROM RHQ_ALERT_NOTIF_LOG WHERE SENDER IS NULL
</statement>
</schema-directSQL>
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" />
</schemaSpec>
<schemaSpec version="2.70.5">
<!-- remove first-class alert notification structures from definition side of the model-->
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_oid" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="email_address" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="role_id" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
<schema-deleteColumn table="RHQ_ALERT_DEFINITION" column="operation_def_id" />
</schemaSpec>
<schemaSpec version="2.70.6">
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
<schema-deleteColumn table="RHQ_ALERT" column="triggered_operation" />
</schemaSpec>
<schemaSpec version="2.70.7">
<schema-directSQL ignoreError="true">
<statement desc="Recreating RHQ_ALERT_IDX_ALERT as non-unique index">
CREATE INDEX RHQ_ALERT_IDX_ALERT ON RHQ_ALERT_NOTIF_LOG (alert_id)
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.70.8">
<!-- only set the sender columns to NON-NULL after the CustomAlertSenderUpgradeTask completes -->
<schema-alterColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_NAME" nullable="FALSE" />
<schema-alterColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" nullable="FALSE" />
</schemaSpec>
<!-- RHQ Advisory Representation -->
<schemaSpec version="2.71">
<schema-createSequence name="RHQ_ADVISORY_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_ADVISORY">
CREATE TABLE RHQ_ADVISORY ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_ADVISORY" column="ID" nullable="false" columnType="INTEGER" />
<schema-addColumn table="RHQ_ADVISORY" column="ADVISORY" precision="64" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ADVISORY" column="ADVISORY" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_TYPE" precision="64" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ADVISORY" column="ADVISORY_TYPE" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_REL" precision="64" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_NAME" precision="64" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ADVISORY" column="DESCRIPTION" precision="4000" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ADVISORY" column="SYNOPSIS" precision="4000" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ADVISORY" column="SYNOPSIS" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY" column="TOPIC" precision="4000" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ADVISORY" column="SOLUTION" precision="4000" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ADVISORY" column="SEVERITY" precision="64" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ADVISORY" column="ISSUE_DATE" columnType="LONG" />
<schema-addColumn table="RHQ_ADVISORY" column="UPDATE_DATE" columnType="LONG" />
<schema-addColumn table="RHQ_ADVISORY" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY" column="CTIME" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL ignoreError="true">
<statement>
CREATE UNIQUE INDEX RHQ_ADVISORY_NAME_UQ ON RHQ_ADVISORY ( ADVISORY_NAME )
</statement>
</schema-directSQL>
<schema-directSQL ignoreError="true">
<statement>
CREATE UNIQUE INDEX RHQ_ADVISORY_UQ ON RHQ_ADVISORY ( ADVISORY )
</statement>
</schema-directSQL>
<schema-directSQL ignoreError="true">
<statement>
CREATE INDEX RHQ_ADVISORY_UDATE_IDX ON RHQ_ADVISORY (UPDATE_DATE )
</statement>
</schema-directSQL>
<schema-createSequence name="RHQ_ADVISORY_PACKAGE_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement>
CREATE TABLE RHQ_ADVISORY_PACKAGE ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="ID" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="ADVISORY_ID" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="PACKAGE_VERSION_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="PACKAGE_VERSION_ID" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL ignoreError="true">
<statement>
CREATE UNIQUE INDEX RHQ_ADVISORY_PACKAGE_IDX ON RHQ_ADVISORY_PACKAGE ( ADVISORY_ID, PACKAGE_VERSION_ID )
</statement>
<statement>
ALTER TABLE RHQ_ADVISORY_PACKAGE
ADD CONSTRAINT RHQ_AP_ADVISORY_ID_FKEY
FOREIGN KEY ( ADVISORY_ID )
REFERENCES RHQ_ADVISORY ( ID )
</statement>
<statement>
ALTER TABLE RHQ_ADVISORY_PACKAGE
ADD CONSTRAINT RHQ_AP_PACKAGE_VERSION_ID_FK
FOREIGN KEY ( PACKAGE_VERSION_ID )
REFERENCES RHQ_PACKAGE_VERSION ( ID )
</statement>
</schema-directSQL>
<schema-createSequence name="RHQ_CVE_ID_SEQ" initial="101" />
<schema-directSQL>
<statement>
CREATE TABLE RHQ_CVE ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_CVE" column="ID" nullable="false" />
<schema-addColumn table="RHQ_CVE" column="NAME" precision="64" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_CVE" column="NAME" nullable="false" />
<schema-createSequence name="RHQ_ADVISORY_CVE_ID_SEQ" initial="10001"/>
<schema-directSQL>
<statement>
CREATE TABLE RHQ_ADVISORY_CVE ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="ID" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_CVE" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="ADVISORY_ID" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_CVE" column="CVE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="CVE_ID" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_CVE" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL ignoreError="true">
<statement>
CREATE UNIQUE INDEX RHQ_ADVISORY_CVE_IDX ON RHQ_ADVISORY_CVE ( ADVISORY_ID, CVE_ID )
</statement>
<statement>
ALTER TABLE RHQ_ADVISORY_CVE
ADD CONSTRAINT RHQ_ACVE_ADVISORY_ID_FK
FOREIGN KEY ( ADVISORY_ID )
REFERENCES RHQ_ADVISORY ( ID )
</statement>
<statement>
ALTER TABLE RHQ_ADVISORY_CVE
ADD CONSTRAINT RHQ_ACVE_CVE_ID_FK
FOREIGN KEY ( CVE_ID )
REFERENCES RHQ_CVE ( ID )
</statement>
</schema-directSQL>
<schema-createSequence name="RHQ_ADVISORY_BUGLIST_SEQ" initial="10001" />
<schema-directSQL>
<statement>
CREATE TABLE RHQ_ADVISORY_BUGLIST ( ID INTEGER PRIMARY KEY)
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="ID" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="ADVISORY_ID" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="BUG_ID" PRECISION="256" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="BUG_ID" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL ignoreError="true">
<statement>
CREATE UNIQUE INDEX RHQ_ADVISORY_BUG_IDX ON RHQ_ADVISORY_BUGLIST ( ADVISORY_ID, BUG_ID )
</statement>
<statement>
ALTER TABLE RHQ_ADVISORY_BUGLIST
ADD CONSTRAINT RHQ_AB_ADVISORY_ID_FK
FOREIGN KEY ( ADVISORY_ID )
REFERENCES RHQ_ADVISORY ( ID )
</statement>
</schema-directSQL>
<schema-directSQL>
<statement>
CREATE TABLE RHQ_REPO_ADVISORY ( REPO_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_REPO_ADVISORY" column="REPO_ID" nullable="false" />
<schema-addColumn table="RHQ_REPO_ADVISORY" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_REPO_ADVISORY" column="ADVISORY_ID" nullable="false" />
<schema-addColumn table="RHQ_REPO_ADVISORY" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_REPO_ADVISORY" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_REPO_ADVISORY
ADD CONSTRAINT RHQ_REPO_ADV_MAP_KEY
PRIMARY KEY ( REPO_ID, ADVISORY_ID )
</statement>
<statement>
ALTER TABLE RHQ_REPO_ADVISORY
ADD CONSTRAINT RHQ_RA_REPO_ID_FK
FOREIGN KEY ( REPO_ID )
REFERENCES RHQ_REPO ( ID )
</statement>
<statement>
ALTER TABLE RHQ_REPO_ADVISORY
ADD CONSTRAINT RHQ_RA_ADVISORY_ID_FK
FOREIGN KEY ( ADVISORY_ID )
REFERENCES RHQ_ADVISORY ( ID )
</statement>
</schema-directSQL>
</schemaSpec>
<!-- Adding repo_sync support -->
<schemaSpec version="2.72">
<schema-createSequence name="RHQ_REPO_SYNC_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement>
CREATE TABLE RHQ_REPO_SYNC ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_REPO_SYNC" column="ID" nullable="false" />
<schema-addColumn table="RHQ_REPO_SYNC" column="STATUS" precision="16" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_REPO_SYNC" column="STATUS" nullable="false" />
<schema-addColumn table="RHQ_REPO_SYNC" column="START_TIME" columnType="LONG" />
<schema-alterColumn table="RHQ_REPO_SYNC" column="START_TIME" nullable="false" />
<schema-addColumn table="RHQ_REPO_SYNC" column="END_TIME" columnType="LONG" />
<schema-addColumn table="RHQ_REPO_SYNC" column="RESULTS" columnType="LONGVARCHAR" />
<schema-addColumn table="RHQ_REPO_SYNC" column="PERCENT_COMPLETE" columnType="LONG" />
<schema-addColumn table="RHQ_REPO_SYNC" column="REPO_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_REPO_SYNC" column="REPO_ID" nullable="false" />
<schema-directSQL>
<statement desc="Creating RHQ_REPO_SYNC foreign key relation to RHQ_REPO for scheduled jobs">
ALTER TABLE RHQ_REPO_SYNC
ADD CONSTRAINT RHQ_REPO_SYNC_REPO_ID_FKEY
FOREIGN KEY (REPO_ID)
REFERENCES RHQ_REPO (ID)
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.75">
<schema-addColumn table="RHQ_REPO" column="SYNC_SCHEDULE" columnType="VARCHAR2" precision="64" />
</schemaSpec>
<schemaSpec version="2.76">
<schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_TYPE" columnType="VARCHAR2" precision="20" />
<schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_KEY" columnType="VARCHAR2" precision="128" />
</schemaSpec>
<schemaSpec version="2.78">
<!-- RHQ_BUNDLE_TYPE -->
<schema-createSequence name="RHQ_BUNDLE_TYPE_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_TYPE">
CREATE TABLE RHQ_BUNDLE_TYPE ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_BUNDLE_TYPE" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_TYPE" column="NAME" columnType="VARCHAR2" precision="200" />
<schema-alterColumn table="RHQ_BUNDLE_TYPE" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_TYPE" column="RESOURCE_TYPE_ID" columnType="INTEGER" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_TYPE foreign key relation to RHQ_RESOURCE_TYPE">
ALTER TABLE RHQ_BUNDLE_TYPE
ADD CONSTRAINT RHQ_BT_RESOURCE_TYPE_ID_FK
FOREIGN KEY (RESOURCE_TYPE_ID)
REFERENCES RHQ_RESOURCE_TYPE (ID)
</statement>
</schema-directSQL>
<schema-directSQL ignoreError="true">
<statement desc="Creating RHQ_BUNDLE_TYPE unique constraint">
CREATE UNIQUE INDEX RHQ_BUNDLE_TYPE_UNIQUE ON RHQ_BUNDLE_TYPE (name)
</statement>
</schema-directSQL>
<!-- RHQ_BUNDLE -->
<schema-createSequence name="RHQ_BUNDLE_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE">
CREATE TABLE RHQ_BUNDLE ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_BUNDLE" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE" column="NAME" columnType="VARCHAR2" precision="200" />
<schema-alterColumn table="RHQ_BUNDLE" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
<schema-addColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE" column="PACKAGE_TYPE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE" column="PACKAGE_TYPE_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE" column="REPO_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE" column="REPO_ID" nullable="FALSE" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE foreign key relation to RHQ_BUNDLE_TYPE">
ALTER TABLE RHQ_BUNDLE
ADD CONSTRAINT RHQ_B_BUNDLE_TYPE_ID_FK
FOREIGN KEY (BUNDLE_TYPE_ID)
REFERENCES RHQ_BUNDLE_TYPE (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE foreign key relation to RHQ_REPO">
ALTER TABLE RHQ_BUNDLE
ADD CONSTRAINT RHQ_B_REPO_ID_FK
FOREIGN KEY (REPO_ID)
REFERENCES RHQ_REPO (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE foreign key relation to RHQ_PACKAGE_TYPE">
ALTER TABLE RHQ_BUNDLE
ADD CONSTRAINT RHQ_B_PACKAGE_TYPE_ID_FK
FOREIGN KEY (PACKAGE_TYPE_ID)
REFERENCES RHQ_PACKAGE_TYPE (ID)
</statement>
</schema-directSQL>
<schema-directSQL ignoreError="true">
<statement desc="Creating RHQ_BUNDLE unique constraint">
CREATE UNIQUE INDEX RHQ_BUNDLE_UNIQUE ON RHQ_BUNDLE (bundle_type_id, name)
</statement>
</schema-directSQL>
<!-- RHQ_BUNDLE_VERSION -->
<schema-createSequence name="RHQ_BUNDLE_VERSION_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_VERSION">
CREATE TABLE RHQ_BUNDLE_VERSION ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="NAME" columnType="VARCHAR2" precision="200" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION_ORDER" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION_ORDER" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="CLOB" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ACTION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="CONFIG_DEF_ID" columnType="INTEGER" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_BUNDLE">
ALTER TABLE RHQ_BUNDLE_VERSION
ADD CONSTRAINT RHQ_BV_BUNDLE_ID_FK
FOREIGN KEY (BUNDLE_ID)
REFERENCES RHQ_BUNDLE (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_CONFIG_DEF">
ALTER TABLE RHQ_BUNDLE_VERSION
ADD CONSTRAINT RHQ_BV_CONFIG_DEF_ID_FK
FOREIGN KEY (CONFIG_DEF_ID)
REFERENCES RHQ_CONFIG_DEF (ID)
</statement>
</schema-directSQL>
<schema-directSQL ignoreError="true">
<statement desc="Creating RHQ_BUNDLE_VERSION unique constraint">
CREATE UNIQUE INDEX RHQ_BUNDLE_VERSION_UNIQUE ON RHQ_BUNDLE_VERSION (bundle_id, name, version)
</statement>
</schema-directSQL>
<!-- RHQ_BUNDLE_VERSION_REPO -->
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_VERSION_REPO">
CREATE TABLE RHQ_BUNDLE_VERSION_REPO ( BUNDLE_VERSION_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_BUNDLE_VERSION_REPO" column="BUNDLE_VERSION_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION_REPO" column="REPO_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION_REPO" column="REPO_ID" nullable="FALSE" />
<schema-directSQL>
<statement desc="Creating primary key for RHQ_BUNDLE_VERSION_REPO">
ALTER TABLE RHQ_BUNDLE_VERSION_REPO ADD PRIMARY KEY ( BUNDLE_VERSION_ID, REPO_ID )
</statement>
<statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_BUNDLE_VERSION">
ALTER TABLE RHQ_BUNDLE_VERSION_REPO
ADD CONSTRAINT RHQ_BVR_BUNDLE_VERSION_ID_FK
FOREIGN KEY (BUNDLE_VERSION_ID)
REFERENCES RHQ_BUNDLE_VERSION (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_REPO">
ALTER TABLE RHQ_BUNDLE_VERSION_REPO
ADD CONSTRAINT RHQ_BVR_REPO_ID_FK
FOREIGN KEY (REPO_ID)
REFERENCES RHQ_REPO (ID)
</statement>
</schema-directSQL>
<!-- RHQ_BUNDLE_FILE -->
<schema-createSequence name="RHQ_BUNDLE_FILE_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_FILE">
CREATE TABLE RHQ_BUNDLE_FILE ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_BUNDLE_FILE" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_VERSION_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_VERSION_ID" nullable="FALSE" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_BUNDLE_VERSION">
ALTER TABLE RHQ_BUNDLE_FILE
ADD CONSTRAINT RHQ_BF_BUNDLE_VERSION_ID_FK
FOREIGN KEY (BUNDLE_VERSION_ID)
REFERENCES RHQ_BUNDLE_VERSION (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_PACKAGE_VERSION">
ALTER TABLE RHQ_BUNDLE_FILE
ADD CONSTRAINT RHQ_BF_PACKAGE_VERSION_ID_FK
FOREIGN KEY (PACKAGE_VERSION_ID)
REFERENCES RHQ_PACKAGE_VERSION (ID)
</statement>
</schema-directSQL>
<!-- RHQ_BUNDLE_DESTINATION -->
<schema-createSequence name="RHQ_BUNDLE_DESTINATION_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_DESTINATION">
CREATE TABLE RHQ_BUNDLE_DESTINATION ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_BUNDLE_DESTINATION" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DESTINATION" column="NAME" columnType="VARCHAR2" precision="200" />
<schema-alterColumn table="RHQ_BUNDLE_DESTINATION" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DESTINATION" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
<schema-addColumn table="RHQ_BUNDLE_DESTINATION" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_BUNDLE_DESTINATION" column="CTIME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DESTINATION" column="MTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_BUNDLE_DESTINATION" column="MTIME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DESTINATION" column="BUNDLE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_DESTINATION" column="BUNDLE_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DESTINATION" column="GROUP_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_DESTINATION" column="GROUP_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DESTINATION" column="DEPLOY_DIR" columnType="VARCHAR2" precision="256" />
<schema-alterColumn table="RHQ_BUNDLE_DESTINATION" column="DEPLOY_DIR" nullable="FALSE" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_DESTINATION foreign key relation to RHQ_BUNDLE">
ALTER TABLE RHQ_BUNDLE_DESTINATION
ADD CONSTRAINT RHQ_BD_BUNDLE_ID_FK
FOREIGN KEY (BUNDLE_ID)
REFERENCES RHQ_BUNDLE (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_DESTINATION foreign key relation to RHQ_RESOURCE_GROUP">
ALTER TABLE RHQ_BUNDLE_DESTINATION
ADD CONSTRAINT RHQ_BD_GROUP_ID_FK
FOREIGN KEY (GROUP_ID)
REFERENCES RHQ_RESOURCE_GROUP (ID)
</statement>
</schema-directSQL>
<schema-directSQL ignoreError="true">
<statement desc="Creating RHQ_BUNDLE_DESTINATION unique constraint">
CREATE UNIQUE INDEX RHQ_BUNDLE_DESTINATION_UNIQUE
ON RHQ_BUNDLE_DESTINATION (bundle_id, group_id, deploy_dir)
</statement>
</schema-directSQL>
<!-- RHQ_BUNDLE_DEPLOYMENT -->
<schema-createSequence name="RHQ_BUNDLE_DEPLOYMENT_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_DEPLOYMENT">
CREATE TABLE RHQ_BUNDLE_DEPLOYMENT ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="NAME" columnType="VARCHAR2" precision="200" />
<schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="CTIME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="MTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="MTIME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="BUNDLE_VERSION_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="BUNDLE_DESTINATION_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="BUNDLE_DESTINATION_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="CONFIG_ID" columnType="INTEGER" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="STATUS" columnType="VARCHAR2" precision="16" />
<schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="STATUS" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="ERROR_MESSAGE" columnType="LONGVARCHAR" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="SUBJECT_NAME" columnType="VARCHAR2" precision="255" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="IS_LIVE" columnType="BOOLEAN" />
<schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="IS_LIVE" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="REPLACED_BUNDLE_DEPLOYMENT_ID" columnType="INTEGER" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_BUNDLE_VERSION">
ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
ADD CONSTRAINT RHQ_BD_BUNDLE_VERSION_ID_FK
FOREIGN KEY (BUNDLE_VERSION_ID)
REFERENCES RHQ_BUNDLE_VERSION (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_BUNDLE_DESTINATION">
ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
ADD CONSTRAINT RHQ_BD_B_DESTINATION_ID_FK
FOREIGN KEY (BUNDLE_DESTINATION_ID)
REFERENCES RHQ_BUNDLE_DESTINATION (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_CONFIG">
ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
ADD CONSTRAINT RHQ_BD_CONFIG_ID_FK
FOREIGN KEY (CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_BUNDLE_DEPLOYMENT">
ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
ADD CONSTRAINT RHQ_BD_B_DEPLOYMENT_ID_FK
FOREIGN KEY (REPLACED_BUNDLE_DEPLOYMENT_ID)
REFERENCES RHQ_BUNDLE_DEPLOYMENT (ID)
</statement>
</schema-directSQL>
<!-- RHQ_BUNDLE_RES_DEPLOY -->
<schema-createSequence name="RHQ_BUNDLE_RES_DEPLOY_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_RES_DEPLOY">
CREATE TABLE RHQ_BUNDLE_RES_DEPLOY ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_BUNDLE_RES_DEPLOY" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEPLOY" column="BUNDLE_DEPLOYMENT_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEPLOY" column="BUNDLE_DEPLOYMENT_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEPLOY" column="RESOURCE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEPLOY" column="RESOURCE_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEPLOY" column="STATUS" columnType="VARCHAR2" precision="16" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEPLOY" column="STATUS" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEPLOY" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEPLOY" column="CTIME" nullable="FALSE" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_RES_DEPLOY foreign key relation to BUNDLE_DEPLOYMENT">
ALTER TABLE RHQ_BUNDLE_RES_DEPLOY
ADD CONSTRAINT RHQ_BRD_B_DEPLOYMENT_ID_FK
FOREIGN KEY (BUNDLE_DEPLOYMENT_ID)
REFERENCES RHQ_BUNDLE_DEPLOYMENT (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_RES_DEPLOY foreign key relation to RESOURCE">
ALTER TABLE RHQ_BUNDLE_RES_DEPLOY
ADD CONSTRAINT RHQ_BRD_RESOURCE_ID_FK
FOREIGN KEY (RESOURCE_ID)
REFERENCES RHQ_RESOURCE (ID)
</statement>
</schema-directSQL>
<schema-directSQL ignoreError="true">
<statement desc="Creating RHQ_BUNDLE_RES_DEPLOY unique constraint on dep-resource mapping">
CREATE UNIQUE INDEX RHQ_BUNDLE_RES_DEPLOY_IDX
ON RHQ_BUNDLE_RES_DEPLOY (BUNDLE_DEPLOYMENT_ID, RESOURCE_ID)
</statement>
</schema-directSQL>
<!-- RHQ_BUNDLE_RES_DEP_HIST -->
<schema-createSequence name="RHQ_BUNDLE_RES_DEP_HIST_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_RES_DEP_HIST">
CREATE TABLE RHQ_BUNDLE_RES_DEP_HIST ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="BUNDLE_RES_DEPLOY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="BUNDLE_RES_DEPLOY_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="SUBJECT_NAME" columnType="VARCHAR2" precision="255" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_TIME" columnType="LONG" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_TIME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="ACTION" columnType="VARCHAR2" precision="128" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="ACTION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="INFO" columnType="VARCHAR2" precision="512" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="INFO" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="CATEGORY" columnType="VARCHAR2" precision="32" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="STATUS" columnType="VARCHAR2" precision="16" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="STATUS" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="MESSAGE" columnType="LONGVARCHAR" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="ATTACHMENT" columnType="LONGVARCHAR" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_RES_DEP_HIST foreign key relation to BUNDLE_DEPLOY">
ALTER TABLE RHQ_BUNDLE_RES_DEP_HIST
ADD CONSTRAINT RHQ_BRDH_B_RES_DEPLOY_ID_FK
FOREIGN KEY (BUNDLE_RES_DEPLOY_ID)
REFERENCES RHQ_BUNDLE_RES_DEPLOY (ID)
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.79">
<schema-directSQL>
<statement desc="Normalizing resource group descriptions">
UPDATE RHQ_RESOURCE_GROUP SET DESCRIPTION = NULL WHERE DESCRIPTION = ''
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.81">
<!-- fix for postgres not properly streaming blobs to JDBC clients -->
<schema-directSQL targetDBVendor="postgresql">
<statement desc="Change bytea column to oid in postgres.">
ALTER TABLE RHQ_PACKAGE_BITS ADD COLUMN NEWOID OID
</statement>
<statement desc="Change bytea column to oid in postgres.">
UPDATE RHQ_PACKAGE_BITS t SET NEWOID = (
SELECT oid FROM (
SELECT oid, lowrite(lo_open(oid, 131072), t.bits)
FROM lo_create(0) o(oid)) x)
</statement>
<statement desc="Change bytea column to oid in postgres.">
ALTER TABLE RHQ_PACKAGE_BITS DROP COLUMN BITS
</statement>
<statement desc="Change bytea column to oid in postgres.">
ALTER TABLE RHQ_PACKAGE_BITS RENAME COLUMN NEWOID TO BITS
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.82">
<schema-directSQL>
<statement desc="Creating table RHQ_SAVED_SEARCH">
CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="NAME" columnType="VARCHAR2" precision="200" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="PATTERN" columnType="VARCHAR2" precision="1000" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="PATTERN" nullable="FALSE" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="JPQL_TRANSLATION" columnType="VARCHAR2" precision="4000" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" columnType="LONG" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" nullable="FALSE" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="RESULT_COUNT" columnType="LONG" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
<schema-createSequence name="RHQ_SAVED_SEARCH_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Platforms'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
VALUES (1, 'RESOURCE', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0, 1, true)
</statement>
<statement targetDBVendor="oracle" desc="Inserting global default saved search 'Downed Platforms'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
VALUES (1, 'RESOURCE', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0, 1, 1)
</statement>
</schema-directSQL>
<schema-directSQL>
<statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Servers'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
VALUES (2, 'RESOURCE', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, true)
</statement>
<statement targetDBVendor="oracle" desc="Inserting global default saved search 'Downed Servers'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
VALUES (2, 'RESOURCE', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, 1)
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.83">
<schema-directSQL>
<statement desc="Creating table RHQ_SUBJECT_ROLE_LDAP_MAP">
CREATE TABLE RHQ_SUBJECT_ROLE_LDAP_MAP ( SUBJECT_ID INTEGER, ROLE_ID INTEGER )
</statement>
<statement desc="Creating composite PK for RHQ_SUBJECT_ROLE_LDAP_MAP">
ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
ADD CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAP_PK
PRIMARY KEY ( SUBJECT_ID, ROLE_ID )
</statement>
<statement desc="Creating FK relation to RHQ_SUBJECT table for SUBJECT_ID column">
ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
ADD CONSTRAINT RHQ_SRLM_SUBJECT_ID_FK
FOREIGN KEY (SUBJECT_ID)
REFERENCES RHQ_SUBJECT (ID)
</statement>
<statement desc="Creating FK relation to RHQ_ROLE table for ROLE_ID column">
ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
ADD CONSTRAINT RHQ_SRLM_ROLE_ID_FK
FOREIGN KEY (ROLE_ID)
REFERENCES RHQ_ROLE (ID)
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_SUBJECT_ROLE_LDAP_MAP" column="SUBJECT_ID" nullable="FALSE" />
<schema-alterColumn table="RHQ_SUBJECT_ROLE_LDAP_MAP" column="ROLE_ID" nullable="FALSE" />
<!-- Fixing ldap group authz by adding remaining mapping elements left out(RHQ_ROLE_LDAP_GROUP) -->
<!-- RHQ_ROLE_LDAP_GROUP -->
<schema-createSequence name="RHQ_ROLE_LDAP_GROUP_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_ROLE_LDAP_GROUP">
CREATE TABLE RHQ_ROLE_LDAP_GROUP ( ID INTEGER PRIMARY KEY, ROLE_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_ROLE_LDAP_GROUP" column="ID" nullable="FALSE" />
<schema-alterColumn table="RHQ_ROLE_LDAP_GROUP" column="ROLE_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_ROLE_LDAP_GROUP" column="LDAP_GROUP_NAME" columnType="VARCHAR2" precision="128" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ROLE_LDAP_GROUP
ADD CONSTRAINT RHQ_RLM_ROLE_ID_FK
FOREIGN KEY ( ROLE_ID )
REFERENCES RHQ_ROLE (ID)
</statement>
</schema-directSQL>
<schema-directSQL ignoreError="true">
<statement>
CREATE UNIQUE INDEX RHQ_ROLE_LDAP_GROUP_IDX
ON RHQ_ROLE_LDAP_GROUP ( ROLE_ID, LDAP_GROUP_NAME )
</statement>
</schema-directSQL>
</schemaSpec>
<!-- Remove the old tagging system -->
<schemaSpec version="2.84">
<schema-dropTable table="RHQ_REPO_TAG_MAP"/>
<schema-dropTable table="RHQ_TAG"/>
</schemaSpec>
<!-- The new tagging system -->
<schemaSpec version="2.85">
<schema-createSequence name="RHQ_TAGGING_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_TAGGING">
CREATE TABLE RHQ_TAGGING ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAGGING" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_TAGGING" column="NAMESPACE" columnType="VARCHAR2" precision="20" />
<schema-addColumn table="RHQ_TAGGING" column="SEMANTIC" columnType="VARCHAR2" precision="50" />
<schema-addColumn table="RHQ_TAGGING" column="NAME" columnType="VARCHAR2" precision="100" />
<schema-alterColumn table="RHQ_TAGGING" column="NAME" nullable="FALSE" />
<schema-directSQL>
<statement>
CREATE TABLE RHQ_TAGGING_RESOURCE_MAP ( RESOURCE_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAGGING_RESOURCE_MAP" column="RESOURCE_ID" nullable="false" />
<schema-addColumn table="RHQ_TAGGING_RESOURCE_MAP" column="TAG_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_TAGGING_RESOURCE_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
ADD CONSTRAINT RHQ_TAGGING_RESOURCE_MAP_KEY
PRIMARY KEY ( RESOURCE_ID, TAG_ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
ADD CONSTRAINT RHQ_TRM_RESOURCE_ID_FK
FOREIGN KEY ( RESOURCE_ID )
REFERENCES RHQ_RESOURCE ( ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
ADD CONSTRAINT RHQ_TRM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAGGING ( ID )
</statement>
</schema-directSQL>
<schema-directSQL>
<statement>
CREATE TABLE RHQ_TAGGING_RES_GROUP_MAP ( RESOURCE_GROUP_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAGGING_RES_GROUP_MAP" column="RESOURCE_GROUP_ID" nullable="false" />
<schema-addColumn table="RHQ_TAGGING_RES_GROUP_MAP" column="TAG_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_TAGGING_RES_GROUP_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_TAGGING_RES_GROUP_MAP
ADD CONSTRAINT RHQ_TAGGING_RES_GROUP_MAP_KEY
PRIMARY KEY ( RESOURCE_GROUP_ID, TAG_ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_RES_GROUP_MAP
ADD CONSTRAINT RHQ_TRGM_RESOURCE_GROUP_ID_FK
FOREIGN KEY ( RESOURCE_GROUP_ID )
REFERENCES RHQ_RESOURCE_GROUP ( ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_RES_GROUP_MAP
ADD CONSTRAINT RHQ_TRGM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAGGING ( ID )
</statement>
</schema-directSQL>
<schema-directSQL>
<statement>
CREATE TABLE RHQ_TAGGING_BUNDLE_MAP ( BUNDLE_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAGGING_BUNDLE_MAP" column="BUNDLE_ID" nullable="false" />
<schema-addColumn table="RHQ_TAGGING_BUNDLE_MAP" column="TAG_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_TAGGING_BUNDLE_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
ADD CONSTRAINT RHQ_TAGGING_BUNDLE_MAP_KEY
PRIMARY KEY ( BUNDLE_ID, TAG_ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
ADD CONSTRAINT RHQ_TBM_BUNDLE_ID_FK
FOREIGN KEY ( BUNDLE_ID )
REFERENCES RHQ_BUNDLE ( ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
ADD CONSTRAINT RHQ_TBM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAGGING ( ID )
</statement>
</schema-directSQL>
<schema-directSQL>
<statement>
CREATE TABLE RHQ_TAGGING_BUNDLE_VERSION_MAP ( BUNDLE_VERSION_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAGGING_BUNDLE_VERSION_MAP" column="BUNDLE_VERSION_ID" nullable="false" />
<schema-addColumn table="RHQ_TAGGING_BUNDLE_VERSION_MAP" column="TAG_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_TAGGING_BUNDLE_VERSION_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_VERSION_MAP
ADD CONSTRAINT RHQ_TAGGING_BUNDLE_VER_MAP_KEY
PRIMARY KEY ( BUNDLE_VERSION_ID, TAG_ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_VERSION_MAP
ADD CONSTRAINT RHQ_TBVM_BUNDLE_VERSION_ID_FK
FOREIGN KEY ( BUNDLE_VERSION_ID )
REFERENCES RHQ_BUNDLE_VERSION ( ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_VERSION_MAP
ADD CONSTRAINT RHQ_TBVM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAGGING ( ID )
</statement>
</schema-directSQL>
<schema-directSQL>
<statement>
CREATE TABLE RHQ_TAGGING_BUNDLE_DEPLOY_MAP ( BUNDLE_DEPLOYMENT_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAGGING_BUNDLE_DEPLOY_MAP" column="BUNDLE_DEPLOYMENT_ID" nullable="false" />
<schema-addColumn table="RHQ_TAGGING_BUNDLE_DEPLOY_MAP" column="TAG_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_TAGGING_BUNDLE_DEPLOY_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_DEPLOY_MAP
ADD CONSTRAINT RHQ_TAGGING_BUNDLE_DEP_MAP_KEY
PRIMARY KEY ( BUNDLE_DEPLOYMENT_ID, TAG_ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_DEPLOY_MAP
ADD CONSTRAINT RHQ_TBDM_B_DEPLOYMENT_ID_FK
FOREIGN KEY ( BUNDLE_DEPLOYMENT_ID )
REFERENCES RHQ_BUNDLE_DEPLOYMENT ( ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_DEPLOY_MAP
ADD CONSTRAINT RHQ_TBDM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAGGING ( ID )
</statement>
</schema-directSQL>
<schema-directSQL>
<statement>
CREATE TABLE RHQ_TAGGING_BUNDLE_DEST_MAP ( BUNDLE_DESTINATION_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAGGING_BUNDLE_DEST_MAP" column="BUNDLE_DESTINATION_ID" nullable="false" />
<schema-addColumn table="RHQ_TAGGING_BUNDLE_DEST_MAP" column="TAG_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_TAGGING_BUNDLE_DEST_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_DEST_MAP
ADD CONSTRAINT RHQ_TAGGING_BUNDLE_DES_MAP_KEY
PRIMARY KEY ( BUNDLE_DESTINATION_ID, TAG_ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_DEST_MAP
ADD CONSTRAINT RHQ_TBDM_B_DESTINATION_ID_FK
FOREIGN KEY ( BUNDLE_DESTINATION_ID )
REFERENCES RHQ_BUNDLE_DESTINATION ( ID )
</statement>
<statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_DEST_MAP
ADD CONSTRAINT RHQ_TBDESTM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAGGING ( ID )
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.86">
<schema-directSQL>
<statement desc="Adding MANAGE_BUNDLE permission to overlord">
INSERT INTO RHQ_PERMISSION VALUES(1, 12)
</statement>
<statement desc="Adding MANAGE_BUNDLE permission to superuser">
INSERT INTO RHQ_PERMISSION VALUES(2, 12)
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.87">
<schema-directSQL ignoreError="true">
<statement desc="Drop non-unique RHQ_RES_TYPE_IDX_PLG_NAME index">
DROP INDEX RHQ_RES_TYPE_IDX_PLG_NAME
</statement>
</schema-directSQL>
<schema-directSQL ignoreError="true">
<statement desc="Recreate RHQ_RES_TYPE_IDX_PLG_NAME index as unique">
CREATE UNIQUE INDEX RHQ_RES_TYPE_IDX_PLG_NAME ON RHQ_RESOURCE_TYPE (name, plugin)
</statement>
</schema-directSQL>