// ========================================================================
// Create tables
// ClusterConfigMapping
columns.add(new DBColumnInfo("cluster_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("type_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("version_tag", String.class, 255, null, false));
columns.add(new DBColumnInfo("create_timestamp", Long.class, null, null, false));
columns.add(new DBColumnInfo("selected", Integer.class, 0, null, false));
columns.add(new DBColumnInfo("user_name", String.class, 255, "_db", false));
dbAccessor.createTable("clusterconfigmapping", columns, "cluster_id", "type_name", "create_timestamp");
// Request
columns.clear();
columns.add(new DBColumnInfo("request_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("cluster_id", Long.class, null, null, true));
columns.add(new DBColumnInfo("request_schedule_id", Long.class, null, null, true));
columns.add(new DBColumnInfo("command_name", String.class, 255, null, true));
columns.add(new DBColumnInfo("create_time", Long.class, null, null, true));
columns.add(new DBColumnInfo("end_time", Long.class, null, null, true));
columns.add(new DBColumnInfo("inputs", byte[].class, null, null, true));
columns.add(new DBColumnInfo("request_context", String.class, 255, null, true));
columns.add(new DBColumnInfo("request_type", String.class, 255, null, true));
columns.add(new DBColumnInfo("start_time", Long.class, null, null, false));
columns.add(new DBColumnInfo("status", String.class, 255));
dbAccessor.createTable("request", columns, "request_id");
// RequestSchedule
columns.clear();
columns.add(new DBColumnInfo("schedule_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("cluster_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("description", String.class, 255, null, true));
columns.add(new DBColumnInfo("status", String.class, 255, null, true));
columns.add(new DBColumnInfo("batch_separation_seconds", Integer.class, null, null, true));
columns.add(new DBColumnInfo("batch_toleration_limit", Integer.class, null, null, true));
columns.add(new DBColumnInfo("create_user", String.class, 255, null, true));
columns.add(new DBColumnInfo("create_timestamp", Long.class, null, null, true));
columns.add(new DBColumnInfo("update_user", String.class, 255, null, true));
columns.add(new DBColumnInfo("update_timestamp", Long.class, null, null, true));
columns.add(new DBColumnInfo("minutes", String.class, 10, null, true));
columns.add(new DBColumnInfo("hours", String.class, 10, null, true));
columns.add(new DBColumnInfo("days_of_month", String.class, 10, null, true));
columns.add(new DBColumnInfo("month", String.class, 10, null, true));
columns.add(new DBColumnInfo("day_of_week", String.class, 10, null, true));
columns.add(new DBColumnInfo("yearToSchedule", String.class, 10, null, true));
columns.add(new DBColumnInfo("startTime", String.class, 50, null, true));
columns.add(new DBColumnInfo("endTime", String.class, 50, null, true));
columns.add(new DBColumnInfo("last_execution_status", String.class, 255, null, true));
dbAccessor.createTable("requestschedule", columns, "schedule_id");
// RequestScheduleBatchRequest
columns.clear();
columns.add(new DBColumnInfo("schedule_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("batch_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("request_id", Long.class, null, null, true));
columns.add(new DBColumnInfo("request_type", String.class, 255, null, true));
columns.add(new DBColumnInfo("request_uri", String.class, 1024, null, true));
columns.add(new DBColumnInfo("request_body", byte[].class, null, null, true));
columns.add(new DBColumnInfo("request_status", String.class, 255, null, true));
columns.add(new DBColumnInfo("return_code", Integer.class, null, null, true));
columns.add(new DBColumnInfo("return_message", String.class, 2000, null, true));
dbAccessor.createTable("requestschedulebatchrequest", columns, "schedule_id", "batch_id");
// HostConfigMapping
columns.clear();
columns.add(new DBColumnInfo("cluster_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("host_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("type_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("version_tag", String.class, 255, null, true));
columns.add(new DBColumnInfo("service_name", String.class, 255, null, true));
columns.add(new DBColumnInfo("create_timestamp", Long.class, null, null, false));
columns.add(new DBColumnInfo("selected", Integer.class, 0, null, false));
dbAccessor.createTable("hostconfigmapping", columns, "cluster_id", "host_name", "type_name", "create_timestamp");
// Sequences
columns.clear();
columns.add(new DBColumnInfo("sequence_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("value", Long.class, null, null, false));
dbAccessor.createTable("ambari_sequences", columns, "sequence_name");
// Metainfo
columns.clear();
columns.add(new DBColumnInfo("metainfo_key", String.class, 255, null, false));
columns.add(new DBColumnInfo("metainfo_value", String.class, 255, null, false));
dbAccessor.createTable("metainfo", columns, "metainfo_key");
// ConfigGroup
columns.clear();
columns.add(new DBColumnInfo("group_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("cluster_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("group_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("tag", String.class, 1024, null, false));
columns.add(new DBColumnInfo("description", String.class, 1024, null, true));
columns.add(new DBColumnInfo("create_timestamp", Long.class, null, null, false));
dbAccessor.createTable("configgroup", columns, "group_id");
// ConfigGroupClusterConfigMapping
columns.clear();
columns.add(new DBColumnInfo("config_group_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("cluster_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("config_type", String.class, 255, null, false));
columns.add(new DBColumnInfo("version_tag", String.class, 255, null, false));
columns.add(new DBColumnInfo("user_name", String.class, 255, "_db", true));
columns.add(new DBColumnInfo("create_timestamp", Long.class, null, null, false));
dbAccessor.createTable("confgroupclusterconfigmapping", columns, "config_group_id", "cluster_id", "config_type");
// ConfigGroupHostMapping
columns.clear();
columns.add(new DBColumnInfo("config_group_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("host_name", String.class, 255, null, false));
dbAccessor.createTable("configgrouphostmapping", columns, "config_group_id", "host_name");
// Blueprint
columns.clear();
columns.add(new DBColumnInfo("blueprint_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("stack_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("stack_version", String.class, 255, null, false));
dbAccessor.createTable("blueprint", columns, "blueprint_name");
// Blueprint Config
columns.clear();
columns.add(new DBColumnInfo("blueprint_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("type_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("config_data", byte[].class, null, null, false));
dbAccessor.createTable("blueprint_configuration", columns, "blueprint_name", "type_name");
// HostGroup
columns.clear();
columns.add(new DBColumnInfo("blueprint_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("name", String.class, 255, null, false));
columns.add(new DBColumnInfo("cardinality", String.class, 255, null, false));
dbAccessor.createTable("hostgroup", columns, "blueprint_name", "name");
// HostGroupComponent
columns.clear();
columns.add(new DBColumnInfo("blueprint_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("hostgroup_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("name", String.class, 255, null, false));
dbAccessor.createTable("hostgroup_component", columns, "blueprint_name", "hostgroup_name", "name");
// RequestResourceFilter
columns.clear();
columns.add(new DBColumnInfo("filter_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("request_id", Long.class, null, null, false));
columns.add(new DBColumnInfo("service_name", String.class, 255, null, true));
columns.add(new DBColumnInfo("component_name", String.class, 255, null, true));
columns.add(new DBColumnInfo("hosts", byte[].class, null, null, true));
dbAccessor.createTable("requestresourcefilter", columns, "filter_id");
createQuartzTables();
// ========================================================================
// Add columns
dbAccessor.addColumn("hostcomponentdesiredstate", new DBColumnInfo("maintenance_state", String.class, 32, "OFF", false));
dbAccessor.addColumn("servicedesiredstate", new DBColumnInfo("maintenance_state", String.class, 32, "OFF", false));
dbAccessor.addColumn("hoststate", new DBColumnInfo("maintenance_state", String.class, 512, null, true));
dbAccessor.addColumn("hostcomponentdesiredstate", new DBColumnInfo("admin_state", String.class, 32, null, true));
dbAccessor.addColumn("hosts", new DBColumnInfo("ph_cpu_count", Integer.class, 32, null, true));
dbAccessor.addColumn("clusterstate", new DBColumnInfo("current_stack_version", String.class, 255, null, false));
dbAccessor.addColumn("hostconfigmapping", new DBColumnInfo("user_name", String.class, 255, "_db", false));
dbAccessor.addColumn("stage", new DBColumnInfo("request_context", String.class, 255, null, true));
dbAccessor.addColumn("stage", new DBColumnInfo("cluster_host_info", byte[].class, null, null, true));
dbAccessor.addColumn("clusterconfigmapping", new DBColumnInfo("user_name", String.class, 255, "_db", false));
dbAccessor.addColumn("host_role_command", new DBColumnInfo("end_time", Long.class, null, null, true));
dbAccessor.addColumn("host_role_command", new DBColumnInfo("structured_out", byte[].class, null, null, true));
dbAccessor.addColumn("host_role_command", new DBColumnInfo("command_detail", String.class, 255, null, true));
dbAccessor.addColumn("host_role_command", new DBColumnInfo("custom_command_name", String.class, 255, null, true));
// Alter columns
if (dbType.equals(Configuration.POSTGRES_DB_NAME)) {
if (dbAccessor.tableExists("hostcomponentdesiredconfigmapping")) {