-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Ambari-DDL-MySQL-CREATE.sql
1704 lines (1554 loc) · 82.7 KB
/
Ambari-DDL-MySQL-CREATE.sql
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
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- DROP DATABASE IF EXISTS `ambari`;
-- DROP USER `ambari`;
# delimiter ;
# CREATE DATABASE `ambari` /*!40100 DEFAULT CHARACTER SET utf8 */;
#
# CREATE USER 'ambari' IDENTIFIED BY 'bigdata';
# USE @schema;
-- Set default_storage_engine to InnoDB
-- storage_engine variable should be used for versions prior to MySQL 5.6
set @version_short = substring_index(@@version, '.', 2);
set @major = cast(substring_index(@version_short, '.', 1) as SIGNED);
set @minor = cast(substring_index(@version_short, '.', -1) as SIGNED);
set @engine_stmt = IF((@major >= 5 AND @minor>=6) or @major >= 8, 'SET default_storage_engine=INNODB', 'SET storage_engine=INNODB');
prepare statement from @engine_stmt;
execute statement;
DEALLOCATE PREPARE statement;
CREATE TABLE registries(
id BIGINT NOT NULL,
registy_name VARCHAR(255) NOT NULL,
registry_type VARCHAR(255) NOT NULL,
registry_uri VARCHAR(255) NOT NULL,
CONSTRAINT PK_registries PRIMARY KEY (id));
CREATE TABLE mpacks(
id BIGINT NOT NULL,
mpack_name VARCHAR(255) NOT NULL,
mpack_version VARCHAR(255) NOT NULL,
mpack_uri VARCHAR(255),
registry_id BIGINT,
CONSTRAINT PK_mpacks PRIMARY KEY (id),
CONSTRAINT uni_mpack_name_version UNIQUE(mpack_name, mpack_version),
CONSTRAINT FK_registries FOREIGN KEY (registry_id) REFERENCES registries(id));
CREATE TABLE stack(
stack_id BIGINT NOT NULL,
stack_name VARCHAR(100) NOT NULL,
stack_version VARCHAR(100) NOT NULL,
mpack_id BIGINT,
CONSTRAINT PK_stack PRIMARY KEY (stack_id),
CONSTRAINT FK_mpacks FOREIGN KEY (mpack_id) REFERENCES mpacks(id),
CONSTRAINT UQ_stack UNIQUE (stack_name, stack_version));
CREATE TABLE extension(
extension_id BIGINT NOT NULL,
extension_name VARCHAR(100) NOT NULL,
extension_version VARCHAR(100) NOT NULL,
CONSTRAINT PK_extension PRIMARY KEY (extension_id),
CONSTRAINT UQ_extension UNIQUE (extension_name, extension_version));
CREATE TABLE extensionlink(
link_id BIGINT NOT NULL,
stack_id BIGINT NOT NULL,
extension_id BIGINT NOT NULL,
CONSTRAINT PK_extensionlink PRIMARY KEY (link_id),
CONSTRAINT UQ_extension_link UNIQUE (stack_id, extension_id),
CONSTRAINT FK_extensionlink_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id),
CONSTRAINT FK_extensionlink_extension_id FOREIGN KEY (extension_id) REFERENCES extension(extension_id));
CREATE TABLE adminresourcetype (
resource_type_id INTEGER NOT NULL,
resource_type_name VARCHAR(255) NOT NULL,
CONSTRAINT PK_adminresourcetype PRIMARY KEY (resource_type_id));
CREATE TABLE adminresource (
resource_id BIGINT NOT NULL,
resource_type_id INTEGER NOT NULL,
CONSTRAINT PK_adminresource PRIMARY KEY (resource_id),
CONSTRAINT FK_resource_resource_type_id FOREIGN KEY (resource_type_id) REFERENCES adminresourcetype(resource_type_id));
CREATE TABLE clusters (
cluster_id BIGINT NOT NULL,
resource_id BIGINT NOT NULL,
upgrade_id BIGINT,
cluster_info VARCHAR(255) NOT NULL,
cluster_name VARCHAR(100) NOT NULL UNIQUE,
provisioning_state VARCHAR(255) NOT NULL DEFAULT 'INIT',
security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
desired_cluster_state VARCHAR(255) NOT NULL,
desired_stack_id BIGINT NOT NULL,
CONSTRAINT PK_clusters PRIMARY KEY (cluster_id),
CONSTRAINT FK_clusters_desired_stack_id FOREIGN KEY (desired_stack_id) REFERENCES stack(stack_id),
CONSTRAINT FK_clusters_resource_id FOREIGN KEY (resource_id) REFERENCES adminresource(resource_id));
CREATE TABLE clusterconfig (
config_id BIGINT NOT NULL,
version_tag VARCHAR(100) NOT NULL,
version BIGINT NOT NULL,
type_name VARCHAR(100) NOT NULL,
cluster_id BIGINT NOT NULL,
stack_id BIGINT NOT NULL,
selected SMALLINT NOT NULL DEFAULT 0,
config_data LONGTEXT NOT NULL,
config_attributes LONGTEXT,
create_timestamp BIGINT NOT NULL,
unmapped SMALLINT NOT NULL DEFAULT 0,
selected_timestamp BIGINT NOT NULL DEFAULT 0,
CONSTRAINT PK_clusterconfig PRIMARY KEY (config_id),
CONSTRAINT FK_clusterconfig_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
CONSTRAINT FK_clusterconfig_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id),
CONSTRAINT UQ_config_type_tag UNIQUE (cluster_id, type_name, version_tag),
CONSTRAINT UQ_config_type_version UNIQUE (cluster_id, type_name, version));
CREATE TABLE ambari_configuration (
category_name VARCHAR(100) NOT NULL,
property_name VARCHAR(100) NOT NULL,
property_value VARCHAR(4000) NOT NULL,
CONSTRAINT PK_ambari_configuration PRIMARY KEY (category_name, property_name));
CREATE TABLE serviceconfig (
service_config_id BIGINT NOT NULL,
cluster_id BIGINT NOT NULL,
service_name VARCHAR(255) NOT NULL,
version BIGINT NOT NULL,
create_timestamp BIGINT NOT NULL,
stack_id BIGINT NOT NULL,
user_name VARCHAR(255) NOT NULL DEFAULT '_db',
group_id BIGINT,
note LONGTEXT,
CONSTRAINT PK_serviceconfig PRIMARY KEY (service_config_id),
CONSTRAINT FK_serviceconfig_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id),
CONSTRAINT UQ_scv_service_version UNIQUE (cluster_id, service_name, version));
CREATE TABLE hosts (
host_id BIGINT NOT NULL,
host_name VARCHAR(255) NOT NULL,
cpu_count INTEGER NOT NULL,
cpu_info VARCHAR(255) NOT NULL,
discovery_status VARCHAR(2000) NOT NULL,
host_attributes LONGTEXT NOT NULL,
ipv4 VARCHAR(255),
ipv6 VARCHAR(255),
last_registration_time BIGINT NOT NULL,
os_arch VARCHAR(255) NOT NULL,
os_info VARCHAR(1000) NOT NULL,
os_type VARCHAR(255) NOT NULL,
ph_cpu_count INTEGER,
public_host_name VARCHAR(255),
rack_info VARCHAR(255) NOT NULL,
total_mem BIGINT NOT NULL,
CONSTRAINT PK_hosts PRIMARY KEY (host_id),
CONSTRAINT UQ_hosts_host_name UNIQUE (host_name));
CREATE TABLE serviceconfighosts (
service_config_id BIGINT NOT NULL,
host_id BIGINT NOT NULL,
CONSTRAINT PK_serviceconfighosts PRIMARY KEY (service_config_id, host_id),
CONSTRAINT FK_scvhosts_host_id FOREIGN KEY (host_id) REFERENCES hosts(host_id),
CONSTRAINT FK_scvhosts_scv FOREIGN KEY (service_config_id) REFERENCES serviceconfig(service_config_id));
CREATE TABLE serviceconfigmapping (
service_config_id BIGINT NOT NULL,
config_id BIGINT NOT NULL,
CONSTRAINT PK_serviceconfigmapping PRIMARY KEY (service_config_id, config_id),
CONSTRAINT FK_scvm_config FOREIGN KEY (config_id) REFERENCES clusterconfig(config_id),
CONSTRAINT FK_scvm_scv FOREIGN KEY (service_config_id) REFERENCES serviceconfig(service_config_id));
CREATE TABLE clusterservices (
service_name VARCHAR(255) NOT NULL,
cluster_id BIGINT NOT NULL,
service_enabled INTEGER NOT NULL,
CONSTRAINT PK_clusterservices PRIMARY KEY (service_name, cluster_id),
CONSTRAINT FK_clusterservices_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id));
CREATE TABLE clusterstate (
cluster_id BIGINT NOT NULL,
current_cluster_state VARCHAR(255) NOT NULL,
current_stack_id BIGINT NOT NULL,
CONSTRAINT PK_clusterstate PRIMARY KEY (cluster_id),
CONSTRAINT FK_clusterstate_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
CONSTRAINT FK_cs_current_stack_id FOREIGN KEY (current_stack_id) REFERENCES stack(stack_id));
CREATE TABLE repo_version (
repo_version_id BIGINT NOT NULL,
stack_id BIGINT NOT NULL,
version VARCHAR(255) NOT NULL,
display_name VARCHAR(128) NOT NULL,
repo_type VARCHAR(255) DEFAULT 'STANDARD' NOT NULL,
hidden SMALLINT NOT NULL DEFAULT 0,
resolved TINYINT(1) NOT NULL DEFAULT 0,
legacy TINYINT(1) NOT NULL DEFAULT 0,
version_url VARCHAR(1024),
version_xml MEDIUMTEXT,
version_xsd VARCHAR(512),
parent_id BIGINT,
CONSTRAINT PK_repo_version PRIMARY KEY (repo_version_id),
CONSTRAINT FK_repoversion_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id),
CONSTRAINT UQ_repo_version_display_name UNIQUE (display_name),
CONSTRAINT UQ_repo_version_stack_id UNIQUE (stack_id, version));
CREATE TABLE repo_os (
id BIGINT NOT NULL,
repo_version_id BIGINT NOT NULL,
family VARCHAR(255) NOT NULL DEFAULT '',
ambari_managed TINYINT(1) DEFAULT 1,
CONSTRAINT PK_repo_os_id PRIMARY KEY (id),
CONSTRAINT FK_repo_os_id_repo_version_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id));
CREATE TABLE repo_definition (
id BIGINT NOT NULL,
repo_os_id BIGINT,
repo_name VARCHAR(255) NOT NULL,
repo_id VARCHAR(255) NOT NULL,
base_url MEDIUMTEXT NOT NULL,
distribution MEDIUMTEXT,
components MEDIUMTEXT,
unique_repo TINYINT(1) DEFAULT 1,
mirrors MEDIUMTEXT,
CONSTRAINT PK_repo_definition_id PRIMARY KEY (id),
CONSTRAINT FK_repo_definition_repo_os_id FOREIGN KEY (repo_os_id) REFERENCES repo_os (id));
CREATE TABLE repo_tags (
repo_definition_id BIGINT NOT NULL,
tag VARCHAR(255) NOT NULL,
CONSTRAINT FK_repo_tag_definition_id FOREIGN KEY (repo_definition_id) REFERENCES repo_definition (id));
CREATE TABLE repo_applicable_services (
repo_definition_id BIGINT NOT NULL,
service_name VARCHAR(255) NOT NULL,
CONSTRAINT FK_repo_app_service_def_id FOREIGN KEY (repo_definition_id) REFERENCES repo_definition (id));
CREATE TABLE servicecomponentdesiredstate (
id BIGINT NOT NULL,
component_name VARCHAR(100) NOT NULL,
cluster_id BIGINT NOT NULL,
desired_repo_version_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(100) NOT NULL,
recovery_enabled SMALLINT NOT NULL DEFAULT 0,
repo_state VARCHAR(255) NOT NULL DEFAULT 'NOT_REQUIRED',
CONSTRAINT pk_sc_desiredstate PRIMARY KEY (id),
CONSTRAINT UQ_scdesiredstate_name UNIQUE(component_name, service_name, cluster_id),
CONSTRAINT FK_scds_desired_repo_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id),
CONSTRAINT srvccmponentdesiredstatesrvcnm FOREIGN KEY (service_name, cluster_id) REFERENCES clusterservices (service_name, cluster_id));
CREATE TABLE hostcomponentdesiredstate (
id BIGINT NOT NULL,
cluster_id BIGINT NOT NULL,
component_name VARCHAR(100) NOT NULL,
desired_state VARCHAR(255) NOT NULL,
host_id BIGINT NOT NULL,
service_name VARCHAR(100) NOT NULL,
admin_state VARCHAR(32),
maintenance_state VARCHAR(32) NOT NULL DEFAULT 'ACTIVE',
blueprint_provisioning_state VARCHAR(255) DEFAULT 'NONE',
restart_required TINYINT(1) NOT NULL DEFAULT 0,
CONSTRAINT PK_hostcomponentdesiredstate PRIMARY KEY (id),
CONSTRAINT UQ_hcdesiredstate_name UNIQUE (component_name, service_name, host_id, cluster_id),
CONSTRAINT FK_hcdesiredstate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id),
CONSTRAINT hstcmpnntdesiredstatecmpnntnme FOREIGN KEY (component_name, service_name, cluster_id) REFERENCES servicecomponentdesiredstate (component_name, service_name, cluster_id));
CREATE TABLE hostcomponentstate (
id BIGINT NOT NULL,
cluster_id BIGINT NOT NULL,
component_name VARCHAR(100) NOT NULL,
version VARCHAR(32) NOT NULL DEFAULT 'UNKNOWN',
current_state VARCHAR(255) NOT NULL,
last_live_state VARCHAR(255) NOT NULL DEFAULT 'UNKNOWN',
host_id BIGINT NOT NULL,
service_name VARCHAR(100) NOT NULL,
upgrade_state VARCHAR(32) NOT NULL DEFAULT 'NONE',
CONSTRAINT pk_hostcomponentstate PRIMARY KEY (id),
CONSTRAINT FK_hostcomponentstate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id),
CONSTRAINT hstcomponentstatecomponentname FOREIGN KEY (component_name, service_name, cluster_id) REFERENCES servicecomponentdesiredstate (component_name, service_name, cluster_id));
CREATE INDEX idx_host_component_state on hostcomponentstate(host_id, component_name, service_name, cluster_id);
CREATE TABLE hoststate (
agent_version VARCHAR(255) NOT NULL,
available_mem BIGINT NOT NULL,
current_state VARCHAR(255) NOT NULL,
health_status VARCHAR(255),
host_id BIGINT NOT NULL,
time_in_state BIGINT NOT NULL,
maintenance_state VARCHAR(512),
CONSTRAINT PK_hoststate PRIMARY KEY (host_id),
CONSTRAINT FK_hoststate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id));
CREATE TABLE host_version (
id BIGINT NOT NULL,
repo_version_id BIGINT NOT NULL,
host_id BIGINT NOT NULL,
state VARCHAR(32) NOT NULL,
CONSTRAINT PK_host_version PRIMARY KEY (id),
CONSTRAINT FK_host_version_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id),
CONSTRAINT FK_host_version_repovers_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id),
CONSTRAINT UQ_host_repo UNIQUE(host_id, repo_version_id));
CREATE TABLE servicedesiredstate (
cluster_id BIGINT NOT NULL,
desired_host_role_mapping INTEGER NOT NULL,
desired_repo_version_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
maintenance_state VARCHAR(32) NOT NULL DEFAULT 'ACTIVE',
credential_store_enabled SMALLINT NOT NULL DEFAULT 0,
CONSTRAINT PK_servicedesiredstate PRIMARY KEY (cluster_id, service_name),
CONSTRAINT FK_repo_version_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id),
CONSTRAINT servicedesiredstateservicename FOREIGN KEY (service_name, cluster_id) REFERENCES clusterservices (service_name, cluster_id));
CREATE TABLE adminprincipaltype (
principal_type_id INTEGER NOT NULL,
principal_type_name VARCHAR(255) NOT NULL,
CONSTRAINT PK_adminprincipaltype PRIMARY KEY (principal_type_id));
CREATE TABLE adminprincipal (
principal_id BIGINT NOT NULL,
principal_type_id INTEGER NOT NULL,
CONSTRAINT PK_adminprincipal PRIMARY KEY (principal_id),
CONSTRAINT FK_principal_principal_type_id FOREIGN KEY (principal_type_id) REFERENCES adminprincipaltype(principal_type_id));
CREATE TABLE users (
user_id INTEGER,
principal_id BIGINT NOT NULL,
user_name VARCHAR(255) NOT NULL,
active INTEGER NOT NULL DEFAULT 1,
consecutive_failures INTEGER NOT NULL DEFAULT 0,
active_widget_layouts VARCHAR(1024) DEFAULT NULL,
display_name VARCHAR(255) NOT NULL,
local_username VARCHAR(255) NOT NULL,
create_time BIGINT NOT NULL,
version BIGINT NOT NULL DEFAULT 0,
CONSTRAINT PK_users PRIMARY KEY (user_id),
CONSTRAINT FK_users_principal_id FOREIGN KEY (principal_id) REFERENCES adminprincipal(principal_id),
CONSTRAINT UNQ_users_0 UNIQUE (user_name));
CREATE TABLE user_authentication (
user_authentication_id INTEGER,
user_id INTEGER NOT NULL,
authentication_type VARCHAR(50) NOT NULL,
authentication_key VARCHAR(2048),
create_time BIGINT NOT NULL,
update_time BIGINT NOT NULL,
CONSTRAINT PK_user_authentication PRIMARY KEY (user_authentication_id),
CONSTRAINT FK_user_authentication_users FOREIGN KEY (user_id) REFERENCES users (user_id)
);
CREATE TABLE `groups` (
group_id INTEGER,
principal_id BIGINT NOT NULL,
group_name VARCHAR(255) NOT NULL,
ldap_group INTEGER NOT NULL DEFAULT 0,
group_type VARCHAR(255) NOT NULL DEFAULT 'LOCAL',
CONSTRAINT PK_groups PRIMARY KEY (group_id),
CONSTRAINT FK_groups_principal_id FOREIGN KEY (principal_id) REFERENCES adminprincipal(principal_id),
CONSTRAINT UNQ_groups_0 UNIQUE (group_name, ldap_group));
CREATE TABLE members (
member_id INTEGER,
group_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
CONSTRAINT PK_members PRIMARY KEY (member_id),
CONSTRAINT FK_members_group_id FOREIGN KEY (group_id) REFERENCES `groups` (group_id),
CONSTRAINT FK_members_user_id FOREIGN KEY (user_id) REFERENCES users (user_id),
CONSTRAINT UNQ_members_0 UNIQUE (group_id, user_id));
CREATE TABLE requestschedule (
schedule_id bigint,
cluster_id BIGINT NOT NULL,
description varchar(255),
status varchar(255),
batch_separation_seconds smallint,
batch_toleration_limit smallint,
batch_toleration_limit_per_batch smallint,
pause_after_first_batch VARCHAR(1),
authenticated_user_id INTEGER,
create_user varchar(255),
create_timestamp bigint,
update_user varchar(255),
update_timestamp bigint,
minutes varchar(10),
hours varchar(10),
days_of_month varchar(10),
month varchar(10),
day_of_week varchar(10),
yearToSchedule varchar(10),
startTime varchar(50),
endTime varchar(50),
last_execution_status varchar(255),
CONSTRAINT PK_requestschedule PRIMARY KEY (schedule_id));
CREATE TABLE request (
request_id BIGINT NOT NULL,
cluster_id BIGINT,
request_schedule_id BIGINT,
command_name VARCHAR(255),
create_time BIGINT NOT NULL,
end_time BIGINT NOT NULL,
exclusive_execution TINYINT(1) NOT NULL DEFAULT 0,
inputs LONGBLOB,
request_context VARCHAR(255),
request_type VARCHAR(255),
start_time BIGINT NOT NULL,
status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
cluster_host_info LONGBLOB,
user_name VARCHAR(255),
CONSTRAINT PK_request PRIMARY KEY (request_id),
CONSTRAINT FK_request_schedule_id FOREIGN KEY (request_schedule_id) REFERENCES requestschedule (schedule_id));
CREATE TABLE stage (
stage_id BIGINT NOT NULL,
request_id BIGINT NOT NULL,
cluster_id BIGINT,
skippable SMALLINT DEFAULT 0 NOT NULL,
supports_auto_skip_failure SMALLINT DEFAULT 0 NOT NULL,
log_info VARCHAR(255) NOT NULL,
request_context VARCHAR(255),
command_params LONGBLOB,
host_params LONGBLOB,
command_execution_type VARCHAR(32) NOT NULL DEFAULT 'STAGE',
status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
CONSTRAINT PK_stage PRIMARY KEY (stage_id, request_id),
CONSTRAINT FK_stage_request_id FOREIGN KEY (request_id) REFERENCES request (request_id));
CREATE TABLE host_role_command (
task_id BIGINT NOT NULL,
attempt_count SMALLINT NOT NULL,
retry_allowed SMALLINT DEFAULT 0 NOT NULL,
event LONGTEXT NOT NULL,
exitcode INTEGER NOT NULL,
host_id BIGINT,
last_attempt_time BIGINT NOT NULL,
request_id BIGINT NOT NULL,
role VARCHAR(100),
role_command VARCHAR(255),
stage_id BIGINT NOT NULL,
start_time BIGINT NOT NULL,
original_start_time BIGINT NOT NULL,
end_time BIGINT,
status VARCHAR(100) NOT NULL DEFAULT 'PENDING',
auto_skip_on_failure SMALLINT DEFAULT 0 NOT NULL,
std_error LONGBLOB,
std_out LONGBLOB,
output_log VARCHAR(255) NULL,
error_log VARCHAR(255) NULL,
structured_out LONGBLOB,
command_detail VARCHAR(255),
ops_display_name VARCHAR(255),
custom_command_name VARCHAR(255),
is_background SMALLINT DEFAULT 0 NOT NULL,
CONSTRAINT PK_host_role_command PRIMARY KEY (task_id),
CONSTRAINT FK_host_role_command_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id),
CONSTRAINT FK_host_role_command_stage_id FOREIGN KEY (stage_id, request_id) REFERENCES stage (stage_id, request_id));
CREATE TABLE execution_command (
task_id BIGINT NOT NULL,
command LONGBLOB,
CONSTRAINT PK_execution_command PRIMARY KEY (task_id),
CONSTRAINT FK_execution_command_task_id FOREIGN KEY (task_id) REFERENCES host_role_command (task_id));
CREATE TABLE role_success_criteria (
role VARCHAR(255) NOT NULL,
request_id BIGINT NOT NULL,
stage_id BIGINT NOT NULL,
success_factor DOUBLE NOT NULL,
CONSTRAINT PK_role_success_criteria PRIMARY KEY (role, request_id, stage_id),
CONSTRAINT role_success_criteria_stage_id FOREIGN KEY (stage_id, request_id) REFERENCES stage (stage_id, request_id));
CREATE TABLE requestresourcefilter (
filter_id BIGINT NOT NULL,
request_id BIGINT NOT NULL,
service_name VARCHAR(255),
component_name VARCHAR(255),
hosts LONGBLOB,
CONSTRAINT PK_requestresourcefilter PRIMARY KEY (filter_id),
CONSTRAINT FK_reqresfilter_req_id FOREIGN KEY (request_id) REFERENCES request (request_id));
CREATE TABLE requestoperationlevel (
operation_level_id BIGINT NOT NULL,
request_id BIGINT NOT NULL,
level_name VARCHAR(255),
cluster_name VARCHAR(255),
service_name VARCHAR(255),
host_component_name VARCHAR(255),
host_id BIGINT NULL, -- unlike most host_id columns, this one allows NULLs because the request can be at the service level
CONSTRAINT PK_requestoperationlevel PRIMARY KEY (operation_level_id),
CONSTRAINT FK_req_op_level_req_id FOREIGN KEY (request_id) REFERENCES request (request_id));
CREATE TABLE key_value_store (`key` VARCHAR(255),
`value` LONGTEXT,
CONSTRAINT PK_key_value_store PRIMARY KEY (`key`));
CREATE TABLE hostconfigmapping (
create_timestamp BIGINT NOT NULL,
host_id BIGINT NOT NULL,
cluster_id BIGINT NOT NULL,
type_name VARCHAR(255) NOT NULL,
selected INTEGER NOT NULL DEFAULT 0,
service_name VARCHAR(255),
version_tag VARCHAR(255) NOT NULL,
user_name VARCHAR(255) NOT NULL DEFAULT '_db',
CONSTRAINT PK_hostconfigmapping PRIMARY KEY (create_timestamp, host_id, cluster_id, type_name),
CONSTRAINT FK_hostconfmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
CONSTRAINT FK_hostconfmapping_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id));
CREATE TABLE metainfo (
`metainfo_key` VARCHAR(255),
`metainfo_value` LONGTEXT,
CONSTRAINT PK_metainfo PRIMARY KEY (`metainfo_key`));
CREATE TABLE ClusterHostMapping (
cluster_id BIGINT NOT NULL,
host_id BIGINT NOT NULL,
CONSTRAINT PK_ClusterHostMapping PRIMARY KEY (cluster_id, host_id),
CONSTRAINT FK_clhostmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
CONSTRAINT FK_clusterhostmapping_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id));
CREATE TABLE ambari_sequences (
sequence_name VARCHAR(255),
sequence_value DECIMAL(38) NOT NULL,
CONSTRAINT PK_ambari_sequences PRIMARY KEY (sequence_name));
CREATE TABLE configgroup (
group_id BIGINT,
cluster_id BIGINT NOT NULL,
group_name VARCHAR(255) NOT NULL,
tag VARCHAR(1024) NOT NULL,
description VARCHAR(1024),
create_timestamp BIGINT NOT NULL,
service_name VARCHAR(255),
CONSTRAINT PK_configgroup PRIMARY KEY (group_id),
CONSTRAINT FK_configgroup_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id));
CREATE TABLE confgroupclusterconfigmapping (
config_group_id BIGINT NOT NULL,
cluster_id BIGINT NOT NULL,
config_type VARCHAR(100) NOT NULL,
version_tag VARCHAR(100) NOT NULL,
user_name VARCHAR(100) DEFAULT '_db',
create_timestamp BIGINT NOT NULL,
CONSTRAINT PK_confgroupclustercfgmapping PRIMARY KEY (config_group_id, cluster_id, config_type),
CONSTRAINT FK_cgccm_gid FOREIGN KEY (config_group_id) REFERENCES configgroup (group_id),
CONSTRAINT FK_confg FOREIGN KEY (cluster_id, config_type, version_tag) REFERENCES clusterconfig (cluster_id, type_name, version_tag));
CREATE TABLE configgrouphostmapping (
config_group_id BIGINT NOT NULL,
host_id BIGINT NOT NULL,
CONSTRAINT PK_configgrouphostmapping PRIMARY KEY (config_group_id, host_id),
CONSTRAINT FK_cghm_cgid FOREIGN KEY (config_group_id) REFERENCES configgroup (group_id),
CONSTRAINT FK_cghm_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id));
CREATE TABLE requestschedulebatchrequest (
schedule_id bigint,
batch_id bigint,
request_id bigint,
request_type varchar(255),
request_uri varchar(1024),
request_body LONGBLOB,
request_status varchar(255),
return_code smallint,
return_message varchar(2000),
CONSTRAINT PK_requestschedulebatchrequest PRIMARY KEY (schedule_id, batch_id),
CONSTRAINT FK_rsbatchrequest_schedule_id FOREIGN KEY (schedule_id) REFERENCES requestschedule (schedule_id));
CREATE TABLE blueprint (
blueprint_name VARCHAR(100) NOT NULL,
stack_id BIGINT NOT NULL,
security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
security_descriptor_reference VARCHAR(255),
CONSTRAINT PK_blueprint PRIMARY KEY (blueprint_name),
CONSTRAINT FK_blueprint_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
CREATE TABLE hostgroup (
blueprint_name VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
cardinality VARCHAR(255) NOT NULL,
CONSTRAINT PK_hostgroup PRIMARY KEY (blueprint_name, name),
CONSTRAINT FK_hg_blueprint_name FOREIGN KEY (blueprint_name) REFERENCES blueprint(blueprint_name));
CREATE TABLE hostgroup_component (
blueprint_name VARCHAR(100) NOT NULL,
hostgroup_name VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
provision_action VARCHAR(100),
CONSTRAINT PK_hostgroup_component PRIMARY KEY (blueprint_name, hostgroup_name, name),
CONSTRAINT FK_hgc_blueprint_name FOREIGN KEY (blueprint_name, hostgroup_name) REFERENCES hostgroup(blueprint_name, name));
CREATE TABLE blueprint_configuration (
blueprint_name VARCHAR(100) NOT NULL,
type_name VARCHAR(100) NOT NULL,
config_data LONGTEXT NOT NULL,
config_attributes LONGTEXT,
CONSTRAINT PK_blueprint_configuration PRIMARY KEY (blueprint_name, type_name),
CONSTRAINT FK_cfg_blueprint_name FOREIGN KEY (blueprint_name) REFERENCES blueprint(blueprint_name));
CREATE TABLE blueprint_setting (
id BIGINT NOT NULL,
blueprint_name VARCHAR(100) NOT NULL,
setting_name VARCHAR(100) NOT NULL,
setting_data MEDIUMTEXT NOT NULL,
CONSTRAINT PK_blueprint_setting PRIMARY KEY (id),
CONSTRAINT UQ_blueprint_setting_name UNIQUE(blueprint_name,setting_name),
CONSTRAINT FK_blueprint_setting_name FOREIGN KEY (blueprint_name) REFERENCES blueprint(blueprint_name));
CREATE TABLE hostgroup_configuration (
blueprint_name VARCHAR(100) NOT NULL,
hostgroup_name VARCHAR(100) NOT NULL,
type_name VARCHAR(100) NOT NULL,
config_data LONGTEXT NOT NULL,
config_attributes LONGTEXT,
CONSTRAINT PK_hostgroup_configuration PRIMARY KEY (blueprint_name, hostgroup_name, type_name),
CONSTRAINT FK_hg_cfg_bp_hg_name FOREIGN KEY (blueprint_name, hostgroup_name) REFERENCES hostgroup (blueprint_name, name));
CREATE TABLE viewmain (
view_name VARCHAR(255) NOT NULL,
label VARCHAR(255),
description VARCHAR(2048),
version VARCHAR(255),
build VARCHAR(128),
resource_type_id INTEGER NOT NULL,
icon VARCHAR(255),
icon64 VARCHAR(255),
archive VARCHAR(255),
mask VARCHAR(255),
system_view TINYINT(1) NOT NULL DEFAULT 0,
CONSTRAINT PK_viewmain PRIMARY KEY (view_name),
CONSTRAINT FK_view_resource_type_id FOREIGN KEY (resource_type_id) REFERENCES adminresourcetype(resource_type_id));
CREATE table viewurl(
url_id BIGINT ,
url_name VARCHAR(255) NOT NULL ,
url_suffix VARCHAR(255) NOT NULL,
CONSTRAINT PK_viewurl PRIMARY KEY(url_id)
);
CREATE TABLE viewinstance (
view_instance_id BIGINT,
resource_id BIGINT NOT NULL,
view_name VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
label VARCHAR(255),
description VARCHAR(2048),
visible CHAR(1),
icon VARCHAR(255),
icon64 VARCHAR(255),
xml_driven CHAR(1),
alter_names TINYINT(1) NOT NULL DEFAULT 1,
cluster_handle BIGINT,
cluster_type VARCHAR(100) NOT NULL DEFAULT 'LOCAL_AMBARI',
short_url BIGINT,
CONSTRAINT PK_viewinstance PRIMARY KEY (view_instance_id),
CONSTRAINT FK_instance_url_id FOREIGN KEY (short_url) REFERENCES viewurl(url_id),
CONSTRAINT FK_viewinst_view_name FOREIGN KEY (view_name) REFERENCES viewmain(view_name),
CONSTRAINT FK_viewinstance_resource_id FOREIGN KEY (resource_id) REFERENCES adminresource(resource_id),
CONSTRAINT UQ_viewinstance_name UNIQUE (view_name, name),
CONSTRAINT UQ_viewinstance_name_id UNIQUE (view_instance_id, view_name, name));
CREATE TABLE viewinstancedata (
view_instance_id BIGINT,
view_name VARCHAR(100) NOT NULL,
view_instance_name VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
user_name VARCHAR(100) NOT NULL,
value VARCHAR(2000),
CONSTRAINT PK_viewinstancedata PRIMARY KEY (VIEW_INSTANCE_ID, NAME, USER_NAME),
CONSTRAINT FK_viewinstdata_view_name FOREIGN KEY (view_instance_id, view_name, view_instance_name) REFERENCES viewinstance(view_instance_id, view_name, name));
CREATE TABLE viewinstanceproperty (
view_name VARCHAR(100) NOT NULL,
view_instance_name VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
value VARCHAR(2000),
CONSTRAINT PK_viewinstanceproperty PRIMARY KEY (view_name, view_instance_name, name),
CONSTRAINT FK_viewinstprop_view_name FOREIGN KEY (view_name, view_instance_name) REFERENCES viewinstance(view_name, name));
CREATE TABLE viewparameter (
view_name VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
description VARCHAR(2048),
label VARCHAR(255),
placeholder VARCHAR(255),
default_value VARCHAR(2000),
cluster_config VARCHAR(255),
required CHAR(1),
masked CHAR(1),
CONSTRAINT PK_viewparameter PRIMARY KEY (view_name, name),
CONSTRAINT FK_viewparam_view_name FOREIGN KEY (view_name) REFERENCES viewmain(view_name));
CREATE TABLE viewresource (
view_name VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
plural_name VARCHAR(255),
id_property VARCHAR(255),
subResource_names VARCHAR(255),
provider VARCHAR(255),
service VARCHAR(255),
resource VARCHAR(255),
CONSTRAINT PK_viewresource PRIMARY KEY (view_name, name),
CONSTRAINT FK_viewres_view_name FOREIGN KEY (view_name) REFERENCES viewmain(view_name));
CREATE TABLE viewentity (
id BIGINT NOT NULL,
view_name VARCHAR(100) NOT NULL,
view_instance_name VARCHAR(100) NOT NULL,
class_name VARCHAR(255) NOT NULL,
id_property VARCHAR(255),
CONSTRAINT PK_viewentity PRIMARY KEY (id),
CONSTRAINT FK_viewentity_view_name FOREIGN KEY (view_name, view_instance_name) REFERENCES viewinstance(view_name, name));
CREATE TABLE adminpermission (
permission_id BIGINT NOT NULL,
permission_name VARCHAR(255) NOT NULL,
resource_type_id INTEGER NOT NULL,
permission_label VARCHAR(255),
principal_id BIGINT NOT NULL,
sort_order SMALLINT NOT NULL DEFAULT 1,
CONSTRAINT PK_adminpermission PRIMARY KEY (permission_id),
CONSTRAINT FK_permission_resource_type_id FOREIGN KEY (resource_type_id) REFERENCES adminresourcetype(resource_type_id),
CONSTRAINT FK_permission_principal_id FOREIGN KEY (principal_id) REFERENCES adminprincipal(principal_id),
CONSTRAINT UQ_perm_name_resource_type_id UNIQUE (permission_name, resource_type_id));
CREATE TABLE roleauthorization (
authorization_id VARCHAR(100) NOT NULL,
authorization_name VARCHAR(255) NOT NULL,
CONSTRAINT PK_roleauthorization PRIMARY KEY (authorization_id));
CREATE TABLE permission_roleauthorization (
permission_id BIGINT NOT NULL,
authorization_id VARCHAR(100) NOT NULL,
CONSTRAINT PK_permsn_roleauthorization PRIMARY KEY (permission_id, authorization_id),
CONSTRAINT FK_permission_roleauth_aid FOREIGN KEY (authorization_id) REFERENCES roleauthorization(authorization_id),
CONSTRAINT FK_permission_roleauth_pid FOREIGN KEY (permission_id) REFERENCES adminpermission(permission_id));
CREATE TABLE adminprivilege (
privilege_id BIGINT,
permission_id BIGINT NOT NULL,
resource_id BIGINT NOT NULL,
principal_id BIGINT NOT NULL,
CONSTRAINT PK_adminprivilege PRIMARY KEY (privilege_id),
CONSTRAINT FK_privilege_permission_id FOREIGN KEY (permission_id) REFERENCES adminpermission(permission_id),
CONSTRAINT FK_privilege_principal_id FOREIGN KEY (principal_id) REFERENCES adminprincipal(principal_id),
CONSTRAINT FK_privilege_resource_id FOREIGN KEY (resource_id) REFERENCES adminresource(resource_id));
CREATE TABLE widget (
id BIGINT NOT NULL,
widget_name VARCHAR(255) NOT NULL,
widget_type VARCHAR(255) NOT NULL,
metrics LONGTEXT,
time_created BIGINT NOT NULL,
author VARCHAR(255),
description VARCHAR(2048),
default_section_name VARCHAR(255),
scope VARCHAR(255),
widget_values LONGTEXT,
properties LONGTEXT,
cluster_id BIGINT NOT NULL,
tag VARCHAR(255),
CONSTRAINT PK_widget PRIMARY KEY (id)
);
CREATE TABLE widget_layout (
id BIGINT NOT NULL,
layout_name VARCHAR(255) NOT NULL,
section_name VARCHAR(255) NOT NULL,
scope VARCHAR(255) NOT NULL,
user_name VARCHAR(255) NOT NULL,
display_name VARCHAR(255),
cluster_id BIGINT NOT NULL,
CONSTRAINT PK_widget_layout PRIMARY KEY (id)
);
CREATE TABLE widget_layout_user_widget (
widget_layout_id BIGINT NOT NULL,
widget_id BIGINT NOT NULL,
widget_order smallint,
CONSTRAINT PK_widget_layout_user_widget PRIMARY KEY (widget_layout_id, widget_id),
CONSTRAINT FK_widget_id FOREIGN KEY (widget_id) REFERENCES widget(id),
CONSTRAINT FK_widget_layout_id FOREIGN KEY (widget_layout_id) REFERENCES widget_layout(id));
CREATE TABLE artifact (
artifact_name VARCHAR(100) NOT NULL,
foreign_keys VARCHAR(100) NOT NULL,
artifact_data LONGTEXT NOT NULL,
CONSTRAINT PK_artifact PRIMARY KEY (artifact_name, foreign_keys));
CREATE TABLE topology_request (
id BIGINT NOT NULL,
action VARCHAR(255) NOT NULL,
cluster_id BIGINT NOT NULL,
bp_name VARCHAR(100) NOT NULL,
cluster_properties LONGTEXT,
cluster_attributes LONGTEXT,
description VARCHAR(1024),
provision_action VARCHAR(255),
CONSTRAINT PK_topology_request PRIMARY KEY (id),
CONSTRAINT FK_topology_request_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id));
CREATE TABLE topology_hostgroup (
id BIGINT NOT NULL,
name VARCHAR(255) NOT NULL,
group_properties LONGTEXT,
group_attributes LONGTEXT,
request_id BIGINT NOT NULL,
CONSTRAINT PK_topology_hostgroup PRIMARY KEY (id),
CONSTRAINT FK_hostgroup_req_id FOREIGN KEY (request_id) REFERENCES topology_request(id));
CREATE TABLE topology_host_info (
id BIGINT NOT NULL,
group_id BIGINT NOT NULL,
fqdn VARCHAR(255),
host_id BIGINT,
host_count INTEGER,
predicate VARCHAR(2048),
rack_info VARCHAR(255),
CONSTRAINT PK_topology_host_info PRIMARY KEY (id),
CONSTRAINT FK_hostinfo_group_id FOREIGN KEY (group_id) REFERENCES topology_hostgroup(id),
CONSTRAINT FK_hostinfo_host_id FOREIGN KEY (host_id) REFERENCES hosts(host_id));
CREATE TABLE topology_logical_request (
id BIGINT NOT NULL,
request_id BIGINT NOT NULL,
description VARCHAR(1024),
CONSTRAINT PK_topology_logical_request PRIMARY KEY (id),
CONSTRAINT FK_logicalreq_req_id FOREIGN KEY (request_id) REFERENCES topology_request(id));
CREATE TABLE topology_host_request (
id BIGINT NOT NULL,
logical_request_id BIGINT NOT NULL,
group_id BIGINT NOT NULL,
stage_id BIGINT NOT NULL,
host_name VARCHAR(255),
status VARCHAR(255),
status_message VARCHAR(1024),
CONSTRAINT PK_topology_host_request PRIMARY KEY (id),
CONSTRAINT FK_hostreq_group_id FOREIGN KEY (group_id) REFERENCES topology_hostgroup(id),
CONSTRAINT FK_hostreq_logicalreq_id FOREIGN KEY (logical_request_id) REFERENCES topology_logical_request(id));
CREATE TABLE topology_host_task (
id BIGINT NOT NULL,
host_request_id BIGINT NOT NULL,
type VARCHAR(255) NOT NULL,
CONSTRAINT PK_topology_host_task PRIMARY KEY (id),
CONSTRAINT FK_hosttask_req_id FOREIGN KEY (host_request_id) REFERENCES topology_host_request (id));
CREATE TABLE topology_logical_task (
id BIGINT NOT NULL,
host_task_id BIGINT NOT NULL,
physical_task_id BIGINT,
component VARCHAR(255) NOT NULL,
CONSTRAINT PK_topology_logical_task PRIMARY KEY (id),
CONSTRAINT FK_ltask_hosttask_id FOREIGN KEY (host_task_id) REFERENCES topology_host_task (id),
CONSTRAINT FK_ltask_hrc_id FOREIGN KEY (physical_task_id) REFERENCES host_role_command (task_id));
CREATE TABLE setting (
id BIGINT NOT NULL,
name VARCHAR(255) NOT NULL UNIQUE,
setting_type VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
updated_by VARCHAR(255) NOT NULL DEFAULT '_db',
update_timestamp BIGINT NOT NULL,
CONSTRAINT PK_setting PRIMARY KEY (id)
);
-- Remote Cluster table
CREATE TABLE remoteambaricluster(
cluster_id BIGINT NOT NULL,
name VARCHAR(255) NOT NULL,
username VARCHAR(255) NOT NULL,
url VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
CONSTRAINT PK_remote_ambari_cluster PRIMARY KEY (cluster_id),
CONSTRAINT UQ_remote_ambari_cluster UNIQUE (name));
CREATE TABLE remoteambariclusterservice(
id BIGINT NOT NULL,
cluster_id BIGINT NOT NULL,
service_name VARCHAR(255) NOT NULL,
CONSTRAINT PK_remote_ambari_service PRIMARY KEY (id),
CONSTRAINT FK_remote_ambari_cluster_id FOREIGN KEY (cluster_id) REFERENCES remoteambaricluster(cluster_id)
);
-- Remote Cluster table ends
-- upgrade tables
CREATE TABLE upgrade (
upgrade_id BIGINT NOT NULL,
cluster_id BIGINT NOT NULL,
request_id BIGINT NOT NULL,
direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
orchestration VARCHAR(255) DEFAULT 'STANDARD' NOT NULL,
upgrade_package VARCHAR(255) NOT NULL,
upgrade_package_stack VARCHAR(255) NOT NULL,
upgrade_type VARCHAR(32) NOT NULL,
repo_version_id BIGINT NOT NULL,
skip_failures TINYINT(1) NOT NULL DEFAULT 0,
skip_sc_failures TINYINT(1) NOT NULL DEFAULT 0,
downgrade_allowed TINYINT(1) NOT NULL DEFAULT 1,
revert_allowed TINYINT(1) NOT NULL DEFAULT 0,
suspended TINYINT(1) DEFAULT 0 NOT NULL,
CONSTRAINT PK_upgrade PRIMARY KEY (upgrade_id),
FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),
FOREIGN KEY (request_id) REFERENCES request(request_id),
FOREIGN KEY (repo_version_id) REFERENCES repo_version(repo_version_id)
);
CREATE TABLE upgrade_group (
upgrade_group_id BIGINT NOT NULL,
upgrade_id BIGINT NOT NULL,
group_name VARCHAR(255) DEFAULT '' NOT NULL,
group_title VARCHAR(1024) DEFAULT '' NOT NULL,
CONSTRAINT PK_upgrade_group PRIMARY KEY (upgrade_group_id),
FOREIGN KEY (upgrade_id) REFERENCES upgrade(upgrade_id)
);
CREATE TABLE upgrade_item (
upgrade_item_id BIGINT NOT NULL,
upgrade_group_id BIGINT NOT NULL,
stage_id BIGINT NOT NULL,
state VARCHAR(255) DEFAULT 'NONE' NOT NULL,
hosts TEXT,
tasks TEXT,
item_text TEXT,
CONSTRAINT PK_upgrade_item PRIMARY KEY (upgrade_item_id),
FOREIGN KEY (upgrade_group_id) REFERENCES upgrade_group(upgrade_group_id)
);
CREATE TABLE upgrade_history(
id BIGINT NOT NULL,
upgrade_id BIGINT NOT NULL,
service_name VARCHAR(255) NOT NULL,
component_name VARCHAR(255) NOT NULL,
from_repo_version_id BIGINT NOT NULL,
target_repo_version_id BIGINT NOT NULL,
CONSTRAINT PK_upgrade_hist PRIMARY KEY (id),
CONSTRAINT FK_upgrade_hist_upgrade_id FOREIGN KEY (upgrade_id) REFERENCES upgrade (upgrade_id),
CONSTRAINT FK_upgrade_hist_from_repo FOREIGN KEY (from_repo_version_id) REFERENCES repo_version (repo_version_id),
CONSTRAINT FK_upgrade_hist_target_repo FOREIGN KEY (target_repo_version_id) REFERENCES repo_version (repo_version_id),
CONSTRAINT UQ_upgrade_hist UNIQUE (upgrade_id, component_name, service_name)
);
CREATE TABLE servicecomponent_version(
id BIGINT NOT NULL,
component_id BIGINT NOT NULL,
repo_version_id BIGINT NOT NULL,
state VARCHAR(32) NOT NULL,
user_name VARCHAR(255) NOT NULL,
CONSTRAINT PK_sc_version PRIMARY KEY (id),
CONSTRAINT FK_scv_component_id FOREIGN KEY (component_id) REFERENCES servicecomponentdesiredstate (id),
CONSTRAINT FK_scv_repo_version_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id)
);
CREATE TABLE ambari_operation_history(
id BIGINT NOT NULL,
from_version VARCHAR(255) NOT NULL,
to_version VARCHAR(255) NOT NULL,
start_time BIGINT NOT NULL,
end_time BIGINT,
operation_type VARCHAR(255) NOT NULL,
comments TEXT,
CONSTRAINT PK_ambari_operation_history PRIMARY KEY (id)
);
-- tasks indices --
CREATE INDEX idx_stage_request_id ON stage (request_id);
CREATE INDEX idx_hrc_request_id ON host_role_command (request_id);
CREATE INDEX idx_hrc_status_role ON host_role_command (status, role);
CREATE INDEX idx_rsc_request_id ON role_success_criteria (request_id);
-- ------ altering tables by creating foreign keys ----------
-- #1: This should always be an exceptional case. FK constraints should be inlined in table definitions when possible
-- (reorder table definitions if necessary).
-- #2: Oracle has a limitation of 30 chars in the constraint names name, and we should use the same constraint names in all DB types.
ALTER TABLE clusters ADD CONSTRAINT FK_clusters_upgrade_id FOREIGN KEY (upgrade_id) REFERENCES upgrade (upgrade_id);
-- Kerberos
CREATE TABLE kerberos_principal (
principal_name VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
is_service SMALLINT NOT NULL DEFAULT 1,
cached_keytab_path VARCHAR(255),
CONSTRAINT PK_kerberos_principal PRIMARY KEY (principal_name)
);
CREATE TABLE kerberos_keytab (