--
-- Host: localhost    Database: mysql_innodb_cluster_metadata
-- ------------------------------------------------------


--
-- Current Database: `mysql_innodb_cluster_metadata`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysql_innodb_cluster_metadata` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;

USE `mysql_innodb_cluster_metadata`;

--
-- Table structure for table `clusters`
--

CREATE TABLE `clusters` (
  `cluster_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `cluster_name` varchar(40) NOT NULL,
  `default_replicaset` int(10) unsigned DEFAULT NULL,
  `description` text,
  `mysql_user_accounts` blob,
  `options` json DEFAULT NULL,
  `attributes` json DEFAULT NULL,
  PRIMARY KEY (`cluster_id`),
  UNIQUE KEY `cluster_name` (`cluster_name`),
  KEY `default_replicaset` (`default_replicaset`),
  CONSTRAINT `clusters_ibfk_1` FOREIGN KEY (`default_replicaset`) REFERENCES `replicasets` (`replicaset_id`) ON DELETE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `clusters`
--

INSERT INTO `clusters` VALUES (1,'sample',1,'Default Cluster',NULL,NULL,'{\"default\": true, \"opt_gtidSetIsComplete\": false}');

--
-- Table structure for table `hosts`
--

CREATE TABLE `hosts` (
  `host_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `host_name` varchar(256) DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `public_ip_address` varchar(45) DEFAULT NULL,
  `location` varchar(256) NOT NULL,
  `attributes` json DEFAULT NULL,
  `admin_user_account` json DEFAULT NULL,
  PRIMARY KEY (`host_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `hosts`
--

INSERT INTO `hosts` VALUES (1,'__hostname__','',NULL,'',NULL,NULL),(2,'__real_hostname__',NULL,NULL,'','{\"registeredFrom\": \"mysql-router\"}',NULL);

--
-- Table structure for table `instances`
--

CREATE TABLE `instances` (
  `instance_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `host_id` int(10) unsigned NOT NULL,
  `replicaset_id` int(10) unsigned DEFAULT NULL,
  `mysql_server_uuid` varchar(40) NOT NULL,
  `instance_name` varchar(256) NOT NULL,
  `role` enum('HA','readScaleOut') NOT NULL,
  `weight` float DEFAULT NULL,
  `addresses` json NOT NULL,
  `attributes` json DEFAULT NULL,
  `version_token` int(10) unsigned DEFAULT NULL,
  `description` text,
  PRIMARY KEY (`instance_id`),
  UNIQUE KEY `mysql_server_uuid` (`mysql_server_uuid`),
  UNIQUE KEY `instance_name` (`instance_name`),
  KEY `host_id` (`host_id`),
  KEY `replicaset_id` (`replicaset_id`),
  CONSTRAINT `instances_ibfk_1` FOREIGN KEY (`host_id`) REFERENCES `hosts` (`host_id`) ON DELETE RESTRICT,
  CONSTRAINT `instances_ibfk_2` FOREIGN KEY (`replicaset_id`) REFERENCES `replicasets` (`replicaset_id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `instances`
--

INSERT INTO `instances` VALUES __instances__;

--
-- Table structure for table `replicasets`
--

CREATE TABLE `replicasets` (
  `replicaset_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `cluster_id` int(10) unsigned NOT NULL,
  `replicaset_type` enum('gr') NOT NULL,
  `topology_type` enum('pm','mm') NOT NULL DEFAULT 'pm',
  `replicaset_name` varchar(40) NOT NULL,
  `active` tinyint(1) NOT NULL,
  `attributes` json DEFAULT NULL,
  `description` text,
  PRIMARY KEY (`replicaset_id`),
  KEY `cluster_id` (`cluster_id`),
  CONSTRAINT `replicasets_ibfk_1` FOREIGN KEY (`cluster_id`) REFERENCES `clusters` (`cluster_id`) ON DELETE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `replicasets`
--

INSERT INTO `replicasets` VALUES (1,1,'gr','__topology__','default',1,'{\"adopted\": \"0\", \"group_replication_group_name\": \"__replication_group_uuid__\"}',NULL);

--
-- Table structure for table `routers`
--

CREATE TABLE `routers` (
  `router_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `router_name` varchar(256) NOT NULL,
  `host_id` int(10) unsigned NOT NULL,
  `attributes` json DEFAULT NULL,
  PRIMARY KEY (`router_id`),
  UNIQUE KEY `host_id` (`host_id`,`router_name`),
  CONSTRAINT `routers_ibfk_1` FOREIGN KEY (`host_id`) REFERENCES `hosts` (`host_id`) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `routers`
--

INSERT INTO `routers` VALUES (1,'',2,NULL);

--
-- Temporary view structure for view `schema_version`
--

/*!50001 DROP VIEW IF EXISTS `schema_version`*/;
/*!50001 CREATE VIEW `schema_version` AS SELECT 
 1 AS `major`,
 0 AS `minor`,
 1 AS `patch`*/;

--
-- Current Database: `mysql_innodb_cluster_metadata`
--

USE `mysql_innodb_cluster_metadata`;

--
-- Final view structure for view `schema_version`
--

/*!50001 DROP VIEW IF EXISTS `schema_version`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `schema_version` (`major`,`minor`,`patch`) AS select 1 AS `1`,0 AS `0`,1 AS `1` */;


