vitess.io/vitess@v0.16.2/go/vt/vtgr/db/generate_base.go (about) 1 /* 2 Copyright 2017 Shlomi Noach, GitHub Inc. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 /* 18 This file has been copied over from VTOrc package 19 */ 20 21 package db 22 23 // generateSQLBase & generateSQLPatches are lists of SQL statements required to build the orchestrator backend 24 var generateSQLBase = []string{ 25 ` 26 CREATE TABLE IF NOT EXISTS database_instance ( 27 hostname varchar(128) CHARACTER SET ascii NOT NULL, 28 port smallint(5) unsigned NOT NULL, 29 last_checked timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 30 last_seen timestamp NULL DEFAULT NULL, 31 server_id int(10) unsigned NOT NULL, 32 version varchar(128) CHARACTER SET ascii NOT NULL, 33 binlog_format varchar(16) CHARACTER SET ascii NOT NULL, 34 log_bin tinyint(3) unsigned NOT NULL, 35 log_replica_updates tinyint(3) unsigned NOT NULL, 36 binary_log_file varchar(128) CHARACTER SET ascii NOT NULL, 37 binary_log_pos bigint(20) unsigned NOT NULL, 38 source_host varchar(128) CHARACTER SET ascii NOT NULL, 39 source_port smallint(5) unsigned NOT NULL, 40 replica_sql_running tinyint(3) unsigned NOT NULL, 41 replica_io_running tinyint(3) unsigned NOT NULL, 42 source_log_file varchar(128) CHARACTER SET ascii NOT NULL, 43 read_source_log_pos bigint(20) unsigned NOT NULL, 44 relay_source_log_file varchar(128) CHARACTER SET ascii NOT NULL, 45 exec_source_log_pos bigint(20) unsigned NOT NULL, 46 replication_lag_seconds bigint(20) unsigned DEFAULT NULL, 47 replica_lag_seconds bigint(20) unsigned DEFAULT NULL, 48 num_replica_hosts int(10) unsigned NOT NULL, 49 replica_hosts text CHARACTER SET ascii NOT NULL, 50 cluster_name varchar(128) CHARACTER SET ascii NOT NULL, 51 PRIMARY KEY (hostname,port) 52 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 53 `, 54 ` 55 DROP INDEX cluster_name_idx ON database_instance 56 `, 57 ` 58 CREATE INDEX cluster_name_idx_database_instance ON database_instance(cluster_name) 59 `, 60 ` 61 DROP INDEX last_checked_idx ON database_instance 62 `, 63 ` 64 CREATE INDEX last_checked_idx_database_instance ON database_instance(last_checked) 65 `, 66 ` 67 DROP INDEX last_seen_idx ON database_instance 68 `, 69 ` 70 CREATE INDEX last_seen_idx_database_instance ON database_instance(last_seen) 71 `, 72 ` 73 CREATE TABLE IF NOT EXISTS database_instance_maintenance ( 74 database_instance_maintenance_id int(10) unsigned NOT NULL AUTO_INCREMENT, 75 hostname varchar(128) NOT NULL, 76 port smallint(5) unsigned NOT NULL, 77 maintenance_active tinyint(4) DEFAULT NULL, 78 begin_timestamp timestamp NULL DEFAULT NULL, 79 end_timestamp timestamp NULL DEFAULT NULL, 80 owner varchar(128) CHARACTER SET utf8 NOT NULL, 81 reason text CHARACTER SET utf8 NOT NULL, 82 PRIMARY KEY (database_instance_maintenance_id) 83 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 84 `, 85 ` 86 DROP INDEX maintenance_uidx ON database_instance_maintenance 87 `, 88 ` 89 CREATE UNIQUE INDEX maintenance_uidx_database_instance_maintenance ON database_instance_maintenance (maintenance_active, hostname, port) 90 `, 91 ` 92 CREATE TABLE IF NOT EXISTS database_instance_long_running_queries ( 93 hostname varchar(128) NOT NULL, 94 port smallint(5) unsigned NOT NULL, 95 process_id bigint(20) NOT NULL, 96 process_started_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 97 process_user varchar(16) CHARACTER SET utf8 NOT NULL, 98 process_host varchar(128) CHARACTER SET utf8 NOT NULL, 99 process_db varchar(128) CHARACTER SET utf8 NOT NULL, 100 process_command varchar(16) CHARACTER SET utf8 NOT NULL, 101 process_time_seconds int(11) NOT NULL, 102 process_state varchar(128) CHARACTER SET utf8 NOT NULL, 103 process_info varchar(1024) CHARACTER SET utf8 NOT NULL, 104 PRIMARY KEY (hostname,port,process_id) 105 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 106 `, 107 ` 108 DROP INDEX process_started_at_idx ON database_instance_long_running_queries 109 `, 110 ` 111 CREATE INDEX process_started_at_idx_database_instance_long_running_queries ON database_instance_long_running_queries (process_started_at) 112 `, 113 ` 114 CREATE TABLE IF NOT EXISTS audit ( 115 audit_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, 116 audit_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 117 audit_type varchar(128) CHARACTER SET ascii NOT NULL, 118 hostname varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '', 119 port smallint(5) unsigned NOT NULL, 120 message text CHARACTER SET utf8 NOT NULL, 121 PRIMARY KEY (audit_id) 122 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 123 `, 124 ` 125 DROP INDEX audit_timestamp_idx ON audit 126 `, 127 ` 128 CREATE INDEX audit_timestamp_idx_audit ON audit (audit_timestamp) 129 `, 130 ` 131 DROP INDEX host_port_idx ON audit 132 `, 133 ` 134 CREATE INDEX host_port_idx_audit ON audit (hostname, port, audit_timestamp) 135 `, 136 ` 137 CREATE TABLE IF NOT EXISTS host_agent ( 138 hostname varchar(128) NOT NULL, 139 port smallint(5) unsigned NOT NULL, 140 token varchar(128) NOT NULL, 141 last_submitted timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 142 last_checked timestamp NULL DEFAULT NULL, 143 last_seen timestamp NULL DEFAULT NULL, 144 mysql_port smallint(5) unsigned DEFAULT NULL, 145 count_mysql_snapshots smallint(5) unsigned NOT NULL, 146 PRIMARY KEY (hostname) 147 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 148 `, 149 ` 150 DROP INDEX token_idx ON host_agent 151 `, 152 ` 153 CREATE INDEX token_idx_host_agent ON host_agent (token) 154 `, 155 ` 156 DROP INDEX last_submitted_idx ON host_agent 157 `, 158 ` 159 CREATE INDEX last_submitted_idx_host_agent ON host_agent (last_submitted) 160 `, 161 ` 162 DROP INDEX last_checked_idx ON host_agent 163 `, 164 ` 165 CREATE INDEX last_checked_idx_host_agent ON host_agent (last_checked) 166 `, 167 ` 168 DROP INDEX last_seen_idx ON host_agent 169 `, 170 ` 171 CREATE INDEX last_seen_idx_host_agent ON host_agent (last_seen) 172 `, 173 ` 174 CREATE TABLE IF NOT EXISTS agent_seed ( 175 agent_seed_id int(10) unsigned NOT NULL AUTO_INCREMENT, 176 target_hostname varchar(128) NOT NULL, 177 source_hostname varchar(128) NOT NULL, 178 start_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 179 end_timestamp timestamp NOT NULL DEFAULT '1971-01-01 00:00:00', 180 is_complete tinyint(3) unsigned NOT NULL DEFAULT '0', 181 is_successful tinyint(3) unsigned NOT NULL DEFAULT '0', 182 PRIMARY KEY (agent_seed_id) 183 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 184 `, 185 ` 186 DROP INDEX target_hostname_idx ON agent_seed 187 `, 188 ` 189 CREATE INDEX target_hostname_idx_agent_seed ON agent_seed (target_hostname,is_complete) 190 `, 191 ` 192 DROP INDEX source_hostname_idx ON agent_seed 193 `, 194 ` 195 CREATE INDEX source_hostname_idx_agent_seed ON agent_seed (source_hostname,is_complete) 196 `, 197 ` 198 DROP INDEX start_timestamp_idx ON agent_seed 199 `, 200 ` 201 CREATE INDEX start_timestamp_idx_agent_seed ON agent_seed (start_timestamp) 202 `, 203 ` 204 DROP INDEX is_complete_idx ON agent_seed 205 `, 206 ` 207 CREATE INDEX is_complete_idx_agent_seed ON agent_seed (is_complete,start_timestamp) 208 `, 209 ` 210 DROP INDEX is_successful_idx ON agent_seed 211 `, 212 ` 213 CREATE INDEX is_successful_idx_agent_seed ON agent_seed (is_successful, start_timestamp) 214 `, 215 ` 216 CREATE TABLE IF NOT EXISTS agent_seed_state ( 217 agent_seed_state_id int(10) unsigned NOT NULL AUTO_INCREMENT, 218 agent_seed_id int(10) unsigned NOT NULL, 219 state_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 220 state_action varchar(127) NOT NULL, 221 error_message varchar(255) NOT NULL, 222 PRIMARY KEY (agent_seed_state_id) 223 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 224 `, 225 ` 226 DROP INDEX agent_seed_idx ON agent_seed_state 227 `, 228 ` 229 CREATE INDEX agent_seed_idx_agent_seed_state ON agent_seed_state (agent_seed_id, state_timestamp) 230 `, 231 ` 232 CREATE TABLE IF NOT EXISTS host_attributes ( 233 hostname varchar(128) NOT NULL, 234 attribute_name varchar(128) NOT NULL, 235 attribute_value varchar(128) NOT NULL, 236 submit_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 237 expire_timestamp timestamp NULL DEFAULT NULL, 238 PRIMARY KEY (hostname,attribute_name) 239 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 240 `, 241 ` 242 DROP INDEX attribute_name_idx ON host_attributes 243 `, 244 ` 245 CREATE INDEX attribute_name_idx_host_attributes ON host_attributes (attribute_name) 246 `, 247 ` 248 DROP INDEX attribute_value_idx ON host_attributes 249 `, 250 ` 251 CREATE INDEX attribute_value_idx_host_attributes ON host_attributes (attribute_value) 252 `, 253 ` 254 DROP INDEX submit_timestamp_idx ON host_attributes 255 `, 256 ` 257 CREATE INDEX submit_timestamp_idx_host_attributes ON host_attributes (submit_timestamp) 258 `, 259 ` 260 DROP INDEX expire_timestamp_idx ON host_attributes 261 `, 262 ` 263 CREATE INDEX expire_timestamp_idx_host_attributes ON host_attributes (expire_timestamp) 264 `, 265 ` 266 CREATE TABLE IF NOT EXISTS hostname_resolve ( 267 hostname varchar(128) NOT NULL, 268 resolved_hostname varchar(128) NOT NULL, 269 resolved_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 270 PRIMARY KEY (hostname) 271 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 272 `, 273 ` 274 DROP INDEX resolved_timestamp_idx ON hostname_resolve 275 `, 276 ` 277 CREATE INDEX resolved_timestamp_idx_hostname_resolve ON hostname_resolve (resolved_timestamp) 278 `, 279 ` 280 CREATE TABLE IF NOT EXISTS active_node ( 281 anchor tinyint unsigned NOT NULL, 282 hostname varchar(128) CHARACTER SET ascii NOT NULL, 283 token varchar(128) NOT NULL, 284 last_seen_active timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 285 PRIMARY KEY (anchor) 286 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 287 `, 288 ` 289 INSERT IGNORE INTO active_node (anchor, hostname, token, last_seen_active) 290 VALUES (1, '', '', NOW()) 291 `, 292 ` 293 CREATE TABLE IF NOT EXISTS node_health ( 294 hostname varchar(128) CHARACTER SET ascii NOT NULL, 295 token varchar(128) NOT NULL, 296 last_seen_active timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 297 PRIMARY KEY (hostname, token) 298 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 299 `, 300 ` 301 DROP VIEW IF EXISTS _whats_wrong 302 `, 303 ` 304 DROP VIEW IF EXISTS whats_wrong 305 `, 306 ` 307 DROP VIEW IF EXISTS whats_wrong_summary 308 `, 309 ` 310 CREATE TABLE IF NOT EXISTS topology_recovery ( 311 recovery_id bigint unsigned not null auto_increment, 312 hostname varchar(128) NOT NULL, 313 port smallint unsigned NOT NULL, 314 in_active_period tinyint unsigned NOT NULL DEFAULT 0, 315 start_active_period timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 316 end_active_period_unixtime int unsigned, 317 end_recovery timestamp NULL DEFAULT NULL, 318 processing_node_hostname varchar(128) CHARACTER SET ascii NOT NULL, 319 processcing_node_token varchar(128) NOT NULL, 320 successor_hostname varchar(128) DEFAULT NULL, 321 successor_port smallint unsigned DEFAULT NULL, 322 PRIMARY KEY (recovery_id) 323 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 324 `, 325 ` 326 DROP INDEX in_active_start_period_idx ON topology_recovery 327 `, 328 ` 329 CREATE INDEX in_active_start_period_idx_topology_recovery ON topology_recovery (in_active_period, start_active_period) 330 `, 331 ` 332 DROP INDEX start_active_period_idx ON topology_recovery 333 `, 334 ` 335 CREATE INDEX start_active_period_idx_topology_recovery ON topology_recovery (start_active_period) 336 `, 337 ` 338 DROP INDEX hostname_port_active_period_uidx ON topology_recovery 339 `, 340 ` 341 CREATE UNIQUE INDEX hostname_port_active_period_uidx_topology_recovery ON topology_recovery (hostname, port, in_active_period, end_active_period_unixtime) 342 `, 343 ` 344 CREATE TABLE IF NOT EXISTS hostname_unresolve ( 345 hostname varchar(128) NOT NULL, 346 unresolved_hostname varchar(128) NOT NULL, 347 PRIMARY KEY (hostname) 348 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 349 `, 350 ` 351 DROP INDEX unresolved_hostname_idx ON hostname_unresolve 352 `, 353 ` 354 CREATE INDEX unresolved_hostname_idx_hostname_unresolve ON hostname_unresolve (unresolved_hostname) 355 `, 356 ` 357 CREATE TABLE IF NOT EXISTS database_instance_pool ( 358 hostname varchar(128) CHARACTER SET ascii NOT NULL, 359 port smallint(5) unsigned NOT NULL, 360 pool varchar(128) NOT NULL, 361 PRIMARY KEY (hostname, port, pool) 362 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 363 `, 364 ` 365 DROP INDEX pool_idx ON database_instance_pool 366 `, 367 ` 368 CREATE INDEX pool_idx_database_instance_pool ON database_instance_pool (pool) 369 `, 370 ` 371 CREATE TABLE IF NOT EXISTS database_instance_topology_history ( 372 snapshot_unix_timestamp INT UNSIGNED NOT NULL, 373 hostname varchar(128) CHARACTER SET ascii NOT NULL, 374 port smallint(5) unsigned NOT NULL, 375 source_host varchar(128) CHARACTER SET ascii NOT NULL, 376 source_port smallint(5) unsigned NOT NULL, 377 cluster_name tinytext CHARACTER SET ascii NOT NULL, 378 PRIMARY KEY (snapshot_unix_timestamp, hostname, port) 379 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 380 `, 381 ` 382 DROP INDEX cluster_name_idx ON database_instance_topology_history 383 `, 384 ` 385 CREATE INDEX cluster_name_idx_database_instance_topology_history ON database_instance_topology_history (snapshot_unix_timestamp, cluster_name(128)) 386 `, 387 ` 388 CREATE TABLE IF NOT EXISTS candidate_database_instance ( 389 hostname varchar(128) CHARACTER SET ascii NOT NULL, 390 port smallint(5) unsigned NOT NULL, 391 last_suggested TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 392 PRIMARY KEY (hostname, port) 393 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 394 `, 395 ` 396 DROP INDEX last_suggested_idx ON candidate_database_instance 397 `, 398 ` 399 CREATE INDEX last_suggested_idx_candidate_database_instance ON candidate_database_instance (last_suggested) 400 `, 401 ` 402 CREATE TABLE IF NOT EXISTS database_instance_downtime ( 403 hostname varchar(128) NOT NULL, 404 port smallint(5) unsigned NOT NULL, 405 downtime_active tinyint(4) DEFAULT NULL, 406 begin_timestamp timestamp DEFAULT CURRENT_TIMESTAMP, 407 end_timestamp timestamp NULL DEFAULT NULL, 408 owner varchar(128) CHARACTER SET utf8 NOT NULL, 409 reason text CHARACTER SET utf8 NOT NULL, 410 PRIMARY KEY (hostname, port) 411 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 412 `, 413 ` 414 CREATE TABLE IF NOT EXISTS topology_failure_detection ( 415 detection_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, 416 hostname varchar(128) NOT NULL, 417 port smallint unsigned NOT NULL, 418 in_active_period tinyint unsigned NOT NULL DEFAULT '0', 419 start_active_period timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 420 end_active_period_unixtime int unsigned NOT NULL, 421 processing_node_hostname varchar(128) NOT NULL, 422 processcing_node_token varchar(128) NOT NULL, 423 analysis varchar(128) NOT NULL, 424 cluster_name varchar(128) NOT NULL, 425 count_affected_replicas int unsigned NOT NULL, 426 replica_hosts text NOT NULL, 427 PRIMARY KEY (detection_id) 428 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 429 `, 430 ` 431 DROP INDEX hostname_port_active_period_uidx ON topology_failure_detection 432 `, 433 ` 434 DROP INDEX in_active_start_period_idx ON topology_failure_detection 435 `, 436 ` 437 CREATE INDEX in_active_start_period_idx_topology_failure_detection ON topology_failure_detection (in_active_period, start_active_period) 438 `, 439 ` 440 CREATE TABLE IF NOT EXISTS hostname_resolve_history ( 441 resolved_hostname varchar(128) NOT NULL, 442 hostname varchar(128) NOT NULL, 443 resolved_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 444 PRIMARY KEY (resolved_hostname) 445 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 446 `, 447 ` 448 DROP INDEX hostname ON hostname_resolve_history 449 `, 450 ` 451 CREATE INDEX hostname_idx_hostname_resolve_history ON hostname_resolve_history (hostname) 452 `, 453 ` 454 DROP INDEX resolved_timestamp_idx ON hostname_resolve_history 455 `, 456 ` 457 CREATE INDEX resolved_timestamp_idx_hostname_resolve_history ON hostname_resolve_history (resolved_timestamp) 458 `, 459 ` 460 CREATE TABLE IF NOT EXISTS hostname_unresolve_history ( 461 unresolved_hostname varchar(128) NOT NULL, 462 hostname varchar(128) NOT NULL, 463 last_registered TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 464 PRIMARY KEY (unresolved_hostname) 465 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 466 `, 467 ` 468 DROP INDEX hostname ON hostname_unresolve_history 469 `, 470 ` 471 CREATE INDEX hostname_idx_hostname_unresolve_history ON hostname_unresolve_history (hostname) 472 `, 473 ` 474 DROP INDEX last_registered_idx ON hostname_unresolve_history 475 `, 476 ` 477 CREATE INDEX last_registered_idx_hostname_unresolve_history ON hostname_unresolve_history (last_registered) 478 `, 479 ` 480 CREATE TABLE IF NOT EXISTS cluster_domain_name ( 481 cluster_name varchar(128) CHARACTER SET ascii NOT NULL, 482 domain_name varchar(128) NOT NULL, 483 PRIMARY KEY (cluster_name) 484 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 485 `, 486 ` 487 DROP INDEX domain_name_idx ON cluster_domain_name 488 `, 489 ` 490 CREATE INDEX domain_name_idx_cluster_domain_name ON cluster_domain_name (domain_name(32)) 491 `, 492 ` 493 CREATE TABLE IF NOT EXISTS primary_position_equivalence ( 494 equivalence_id bigint unsigned not null auto_increment, 495 primary1_hostname varchar(128) CHARACTER SET ascii NOT NULL, 496 primary1_port smallint(5) unsigned NOT NULL, 497 primary1_binary_log_file varchar(128) CHARACTER SET ascii NOT NULL, 498 primary1_binary_log_pos bigint(20) unsigned NOT NULL, 499 primary2_hostname varchar(128) CHARACTER SET ascii NOT NULL, 500 primary2_port smallint(5) unsigned NOT NULL, 501 primary2_binary_log_file varchar(128) CHARACTER SET ascii NOT NULL, 502 primary2_binary_log_pos bigint(20) unsigned NOT NULL, 503 last_suggested TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 504 PRIMARY KEY (equivalence_id) 505 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 506 `, 507 ` 508 DROP INDEX equivalence_uidx ON primary_position_equivalence 509 `, 510 ` 511 CREATE UNIQUE INDEX equivalence_uidx_primary_position_equivalence ON primary_position_equivalence (primary1_hostname, primary1_port, primary1_binary_log_file, primary1_binary_log_pos, primary2_hostname, primary2_port) 512 `, 513 ` 514 DROP INDEX primary2_idx ON primary_position_equivalence 515 `, 516 ` 517 CREATE INDEX primary2_idx_primary_position_equivalence ON primary_position_equivalence (primary2_hostname, primary2_port, primary2_binary_log_file, primary2_binary_log_pos) 518 `, 519 ` 520 DROP INDEX last_suggested_idx ON primary_position_equivalence 521 `, 522 ` 523 CREATE INDEX last_suggested_idx_primary_position_equivalence ON primary_position_equivalence (last_suggested) 524 `, 525 ` 526 CREATE TABLE IF NOT EXISTS async_request ( 527 request_id bigint unsigned NOT NULL AUTO_INCREMENT, 528 command varchar(128) charset ascii not null, 529 hostname varchar(128) NOT NULL, 530 port smallint(5) unsigned NOT NULL, 531 destination_hostname varchar(128) NOT NULL, 532 destination_port smallint(5) unsigned NOT NULL, 533 pattern text CHARACTER SET utf8 NOT NULL, 534 gtid_hint varchar(32) charset ascii not null, 535 begin_timestamp timestamp NULL DEFAULT NULL, 536 end_timestamp timestamp NULL DEFAULT NULL, 537 story text CHARACTER SET utf8 NOT NULL, 538 PRIMARY KEY (request_id) 539 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 540 `, 541 ` 542 DROP INDEX begin_timestamp_idx ON async_request 543 `, 544 ` 545 CREATE INDEX begin_timestamp_idx_async_request ON async_request (begin_timestamp) 546 `, 547 ` 548 DROP INDEX end_timestamp_idx ON async_request 549 `, 550 ` 551 CREATE INDEX end_timestamp_idx_async_request ON async_request (end_timestamp) 552 `, 553 ` 554 CREATE TABLE IF NOT EXISTS blocked_topology_recovery ( 555 hostname varchar(128) NOT NULL, 556 port smallint(5) unsigned NOT NULL, 557 cluster_name varchar(128) NOT NULL, 558 analysis varchar(128) NOT NULL, 559 last_blocked_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 560 blocking_recovery_id bigint unsigned, 561 PRIMARY KEY (hostname, port) 562 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 563 `, 564 ` 565 DROP INDEX cluster_blocked_idx ON blocked_topology_recovery 566 `, 567 ` 568 CREATE INDEX cluster_blocked_idx_blocked_topology_recovery ON blocked_topology_recovery (cluster_name, last_blocked_timestamp) 569 `, 570 ` 571 CREATE TABLE IF NOT EXISTS database_instance_last_analysis ( 572 hostname varchar(128) NOT NULL, 573 port smallint(5) unsigned NOT NULL, 574 analysis_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 575 analysis varchar(128) NOT NULL, 576 PRIMARY KEY (hostname, port) 577 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 578 `, 579 ` 580 DROP INDEX analysis_timestamp_idx ON database_instance_last_analysis 581 `, 582 ` 583 CREATE INDEX analysis_timestamp_idx_database_instance_last_analysis ON database_instance_last_analysis (analysis_timestamp) 584 `, 585 ` 586 CREATE TABLE IF NOT EXISTS database_instance_analysis_changelog ( 587 changelog_id bigint unsigned not null auto_increment, 588 hostname varchar(128) NOT NULL, 589 port smallint(5) unsigned NOT NULL, 590 analysis_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 591 analysis varchar(128) NOT NULL, 592 PRIMARY KEY (changelog_id) 593 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 594 `, 595 ` 596 DROP INDEX analysis_timestamp_idx ON database_instance_analysis_changelog 597 `, 598 ` 599 CREATE INDEX analysis_timestamp_idx_database_instance_analysis_changelog ON database_instance_analysis_changelog (analysis_timestamp) 600 `, 601 ` 602 CREATE TABLE IF NOT EXISTS node_health_history ( 603 history_id bigint unsigned not null auto_increment, 604 hostname varchar(128) CHARACTER SET ascii NOT NULL, 605 token varchar(128) NOT NULL, 606 first_seen_active timestamp NOT NULL, 607 extra_info varchar(128) CHARACTER SET utf8 NOT NULL, 608 PRIMARY KEY (history_id) 609 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 610 `, 611 ` 612 DROP INDEX first_seen_active_idx ON node_health_history 613 `, 614 ` 615 CREATE INDEX first_seen_active_idx_node_health_history ON node_health_history (first_seen_active) 616 `, 617 ` 618 DROP INDEX hostname_token_idx ON node_health_history 619 `, 620 ` 621 CREATE UNIQUE INDEX hostname_token_idx_node_health_history ON node_health_history (hostname, token) 622 `, 623 ` 624 CREATE TABLE IF NOT EXISTS database_instance_coordinates_history ( 625 history_id bigint unsigned not null auto_increment, 626 hostname varchar(128) NOT NULL, 627 port smallint(5) unsigned NOT NULL, 628 recorded_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 629 binary_log_file varchar(128) NOT NULL, 630 binary_log_pos bigint(20) unsigned NOT NULL, 631 relay_log_file varchar(128) NOT NULL, 632 relay_log_pos bigint(20) unsigned NOT NULL, 633 PRIMARY KEY (history_id) 634 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 635 `, 636 ` 637 DROP INDEX hostname_port_recorded_timestmp_idx ON database_instance_coordinates_history 638 `, 639 ` 640 CREATE INDEX hostname_port_recorded_idx_database_instance_coordinates_history ON database_instance_coordinates_history (hostname, port, recorded_timestamp) 641 `, 642 ` 643 DROP INDEX recorded_timestmp_idx ON database_instance_coordinates_history 644 `, 645 ` 646 CREATE INDEX recorded_timestmp_idx_database_instance_coordinates_history ON database_instance_coordinates_history (recorded_timestamp) 647 `, 648 ` 649 CREATE TABLE IF NOT EXISTS database_instance_binlog_files_history ( 650 history_id bigint unsigned not null auto_increment, 651 hostname varchar(128) NOT NULL, 652 port smallint(5) unsigned NOT NULL, 653 binary_log_file varchar(128) NOT NULL, 654 binary_log_pos bigint(20) unsigned NOT NULL, 655 first_seen timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 656 last_seen timestamp NOT NULL DEFAULT '1971-01-01 00:00:00', 657 PRIMARY KEY (history_id) 658 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 659 `, 660 ` 661 DROP INDEX hostname_port_file_idx ON database_instance_binlog_files_history 662 `, 663 ` 664 CREATE UNIQUE INDEX hostname_port_file_idx_database_instance_binlog_files_history ON database_instance_binlog_files_history (hostname, port, binary_log_file) 665 `, 666 ` 667 DROP INDEX last_seen_idx ON database_instance_binlog_files_history 668 `, 669 ` 670 CREATE INDEX last_seen_idx_database_instance_binlog_files_history ON database_instance_binlog_files_history (last_seen) 671 `, 672 ` 673 CREATE TABLE IF NOT EXISTS access_token ( 674 access_token_id bigint unsigned not null auto_increment, 675 public_token varchar(128) NOT NULL, 676 secret_token varchar(128) NOT NULL, 677 generated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 678 generated_by varchar(128) CHARACTER SET utf8 NOT NULL, 679 is_acquired tinyint unsigned NOT NULL DEFAULT '0', 680 PRIMARY KEY (access_token_id) 681 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 682 `, 683 ` 684 DROP INDEX public_token_idx ON access_token 685 `, 686 ` 687 CREATE UNIQUE INDEX public_token_uidx_access_token ON access_token (public_token) 688 `, 689 ` 690 DROP INDEX generated_at_idx ON access_token 691 `, 692 ` 693 CREATE INDEX generated_at_idx_access_token ON access_token (generated_at) 694 `, 695 ` 696 CREATE TABLE IF NOT EXISTS database_instance_recent_relaylog_history ( 697 hostname varchar(128) NOT NULL, 698 port smallint(5) unsigned NOT NULL, 699 current_relay_log_file varchar(128) NOT NULL, 700 current_relay_log_pos bigint(20) unsigned NOT NULL, 701 current_seen timestamp NOT NULL DEFAULT '1971-01-01 00:00:00', 702 prev_relay_log_file varchar(128) NOT NULL, 703 prev_relay_log_pos bigint(20) unsigned NOT NULL, 704 prev_seen timestamp NOT NULL DEFAULT '1971-01-01 00:00:00', 705 PRIMARY KEY (hostname, port) 706 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 707 `, 708 ` 709 DROP INDEX current_seen_idx ON database_instance_recent_relaylog_history 710 `, 711 ` 712 CREATE INDEX current_seen_idx_database_instance_recent_relaylog_history ON database_instance_recent_relaylog_history (current_seen) 713 `, 714 ` 715 CREATE TABLE IF NOT EXISTS orchestrator_metadata ( 716 anchor tinyint unsigned NOT NULL, 717 last_deployed_version varchar(128) CHARACTER SET ascii NOT NULL, 718 last_deployed_timestamp timestamp NOT NULL, 719 PRIMARY KEY (anchor) 720 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 721 `, 722 ` 723 CREATE TABLE IF NOT EXISTS orchestrator_db_deployments ( 724 deployed_version varchar(128) CHARACTER SET ascii NOT NULL, 725 deployed_timestamp timestamp NOT NULL, 726 PRIMARY KEY (deployed_version) 727 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 728 `, 729 ` 730 CREATE TABLE IF NOT EXISTS global_recovery_disable ( 731 disable_recovery tinyint unsigned NOT NULL COMMENT 'Insert 1 to disable recovery globally', 732 PRIMARY KEY (disable_recovery) 733 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 734 `, 735 ` 736 CREATE TABLE IF NOT EXISTS topology_recovery_steps ( 737 recovery_step_id bigint unsigned not null auto_increment, 738 recovery_uid varchar(128) CHARACTER SET ascii NOT NULL, 739 audit_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 740 message text CHARACTER SET utf8 NOT NULL, 741 PRIMARY KEY (recovery_step_id) 742 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 743 `, 744 ` 745 CREATE TABLE IF NOT EXISTS raft_store ( 746 store_id bigint unsigned not null auto_increment, 747 store_key varbinary(512) not null, 748 store_value blob not null, 749 PRIMARY KEY (store_id) 750 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 751 `, 752 ` 753 CREATE INDEX store_key_idx_raft_store ON raft_store (store_key) 754 `, 755 ` 756 CREATE TABLE IF NOT EXISTS raft_log ( 757 log_index bigint unsigned not null auto_increment, 758 term bigint not null, 759 log_type int not null, 760 data blob not null, 761 PRIMARY KEY (log_index) 762 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 763 `, 764 ` 765 CREATE TABLE IF NOT EXISTS raft_snapshot ( 766 snapshot_id bigint unsigned not null auto_increment, 767 snapshot_name varchar(128) CHARACTER SET utf8 NOT NULL, 768 snapshot_meta varchar(4096) CHARACTER SET utf8 NOT NULL, 769 PRIMARY KEY (snapshot_id) 770 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 771 `, 772 ` 773 CREATE UNIQUE INDEX snapshot_name_uidx_raft_snapshot ON raft_snapshot (snapshot_name) 774 `, 775 ` 776 CREATE TABLE IF NOT EXISTS database_instance_peer_analysis ( 777 peer varchar(128) NOT NULL, 778 hostname varchar(128) NOT NULL, 779 port smallint(5) unsigned NOT NULL, 780 analysis_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 781 analysis varchar(128) NOT NULL, 782 PRIMARY KEY (peer, hostname, port) 783 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 784 `, 785 ` 786 CREATE TABLE IF NOT EXISTS database_instance_tls ( 787 hostname varchar(128) CHARACTER SET ascii NOT NULL, 788 port smallint(5) unsigned NOT NULL, 789 required tinyint unsigned NOT NULL DEFAULT 0, 790 PRIMARY KEY (hostname,port) 791 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 792 `, 793 ` 794 CREATE TABLE IF NOT EXISTS cluster_injected_pseudo_gtid ( 795 cluster_name varchar(128) NOT NULL, 796 time_injected timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 797 PRIMARY KEY (cluster_name) 798 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 799 `, 800 ` 801 CREATE TABLE IF NOT EXISTS hostname_ips ( 802 hostname varchar(128) CHARACTER SET ascii NOT NULL, 803 ipv4 varchar(128) CHARACTER SET ascii NOT NULL, 804 ipv6 varchar(128) CHARACTER SET ascii NOT NULL, 805 last_updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 806 PRIMARY KEY (hostname) 807 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 808 `, 809 ` 810 CREATE TABLE IF NOT EXISTS database_instance_tags ( 811 hostname varchar(128) CHARACTER SET ascii NOT NULL, 812 port smallint(5) unsigned NOT NULL, 813 tag_name varchar(128) CHARACTER SET utf8 NOT NULL, 814 tag_value varchar(128) CHARACTER SET utf8 NOT NULL, 815 last_updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 816 PRIMARY KEY (hostname, port, tag_name) 817 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 818 `, 819 ` 820 CREATE INDEX tag_name_idx_database_instance_tags ON database_instance_tags (tag_name) 821 `, 822 ` 823 CREATE TABLE IF NOT EXISTS database_instance_stale_binlog_coordinates ( 824 hostname varchar(128) CHARACTER SET ascii NOT NULL, 825 port smallint(5) unsigned NOT NULL, 826 binary_log_file varchar(128) NOT NULL, 827 binary_log_pos bigint(20) unsigned NOT NULL, 828 first_seen timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 829 PRIMARY KEY (hostname, port) 830 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 831 `, 832 ` 833 CREATE INDEX first_seen_idx_database_instance_stale_binlog_coordinates ON database_instance_stale_binlog_coordinates (first_seen) 834 `, 835 ` 836 CREATE TABLE IF NOT EXISTS vitess_tablet ( 837 hostname varchar(128) CHARACTER SET ascii NOT NULL, 838 port smallint(5) unsigned NOT NULL, 839 keyspace varchar(128) CHARACTER SET ascii NOT NULL, 840 shard varchar(128) CHARACTER SET ascii NOT NULL, 841 cell varchar(128) CHARACTER SET ascii NOT NULL, 842 tablet_type smallint(5) NOT NULL, 843 primary_timestamp timestamp NOT NULL, 844 info varchar(512) CHARACTER SET ascii NOT NULL, 845 PRIMARY KEY (hostname, port) 846 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 847 `, 848 ` 849 CREATE INDEX cell_idx_vitess_tablet ON vitess_tablet (cell) 850 `, 851 ` 852 CREATE INDEX ks_idx_vitess_tablet ON vitess_tablet (keyspace, shard) 853 `, 854 ` 855 CREATE TABLE IF NOT EXISTS vitess_keyspace ( 856 keyspace varchar(128) CHARACTER SET ascii NOT NULL, 857 keyspace_type smallint(5) NOT NULL, 858 durability_policy varchar(512) CHARACTER SET ascii NOT NULL, 859 PRIMARY KEY (keyspace) 860 ) ENGINE=InnoDB DEFAULT CHARSET=ascii 861 `, 862 }