-- MySQL dump 10.13  Distrib 5.7.28, for Linux (x86_64)
--
-- Host: localhost    Database: nexus_provision
-- ------------------------------------------------------
-- Server version	5.7.28

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `alembic_version`
--

DROP TABLE IF EXISTS `alembic_version`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `alembic_version` (
  `version_num` varchar(32) NOT NULL,
  PRIMARY KEY (`version_num`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `alembic_version`
--

LOCK TABLES `alembic_version` WRITE;
/*!40000 ALTER TABLE `alembic_version` DISABLE KEYS */;
INSERT INTO `alembic_version` VALUES ('8e8912d3ff60');
/*!40000 ALTER TABLE `alembic_version` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `app_dependency`
--

DROP TABLE IF EXISTS `app_dependency`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `app_dependency` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `application_id` int(11) NOT NULL,
  `dependency_id` int(11) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `application_id` (`application_id`),
  KEY `dependency_id` (`dependency_id`),
  CONSTRAINT `app_dependency_ibfk_1` FOREIGN KEY (`application_id`) REFERENCES `application` (`id`),
  CONSTRAINT `app_dependency_ibfk_2` FOREIGN KEY (`dependency_id`) REFERENCES `application` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `app_dependency`
--

LOCK TABLES `app_dependency` WRITE;
/*!40000 ALTER TABLE `app_dependency` DISABLE KEYS */;
/*!40000 ALTER TABLE `app_dependency` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `application`
--

DROP TABLE IF EXISTS `application`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `application` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `app_type` varchar(8) NOT NULL,
  `app_name` varchar(32) NOT NULL,
  `app_version` varchar(64) NOT NULL,
  `app_status` varchar(16) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `app_name` (`app_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `application`
--

LOCK TABLES `application` WRITE;
/*!40000 ALTER TABLE `application` DISABLE KEYS */;
/*!40000 ALTER TABLE `application` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `biz_customer`
--

DROP TABLE IF EXISTS `biz_customer`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `biz_customer` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(255) NOT NULL,
  `type` enum('individual','enterprise') NOT NULL,
  `contact` varchar(64) DEFAULT NULL,
  `mobile` varchar(128) DEFAULT NULL,
  `desc` varchar(1024) DEFAULT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `biz_customer`
--

LOCK TABLES `biz_customer` WRITE;
/*!40000 ALTER TABLE `biz_customer` DISABLE KEYS */;
/*!40000 ALTER TABLE `biz_customer` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `biz_product`
--

DROP TABLE IF EXISTS `biz_product`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `biz_product` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `license_no` varchar(128) NOT NULL,
  `customer_id` int(11) NOT NULL,
  `vendor_id` int(11) NOT NULL,
  `type` enum('trial','formal') NOT NULL,
  `status` enum('unused','deleted','locked','in_use') NOT NULL,
  `license_key` varchar(128) NOT NULL,
  `capacity` int(11) NOT NULL,
  `valid_duration` int(11) DEFAULT NULL,
  `expiration` datetime DEFAULT NULL,
  `description` varchar(256) DEFAULT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `license_no` (`license_no`),
  KEY `vendor_id` (`vendor_id`),
  CONSTRAINT `biz_product_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `biz_vendor` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `biz_product`
--

LOCK TABLES `biz_product` WRITE;
/*!40000 ALTER TABLE `biz_product` DISABLE KEYS */;
/*!40000 ALTER TABLE `biz_product` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `biz_product_vendor_attr`
--

DROP TABLE IF EXISTS `biz_product_vendor_attr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `biz_product_vendor_attr` (
  `product_id` int(11) NOT NULL,
  `attr_name` varchar(32) NOT NULL,
  `attr_value` varchar(4096) DEFAULT NULL,
  PRIMARY KEY (`product_id`),
  KEY `ix_biz_product_vendor_attr_attr_name` (`attr_name`),
  CONSTRAINT `biz_product_vendor_attr_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `biz_product` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `biz_product_vendor_attr`
--

LOCK TABLES `biz_product_vendor_attr` WRITE;
/*!40000 ALTER TABLE `biz_product_vendor_attr` DISABLE KEYS */;
/*!40000 ALTER TABLE `biz_product_vendor_attr` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `biz_vendor`
--

DROP TABLE IF EXISTS `biz_vendor`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `biz_vendor` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `vendor_name` varchar(128) DEFAULT NULL,
  `desc` varchar(1024) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `vendor_name` (`vendor_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `biz_vendor`
--

LOCK TABLES `biz_vendor` WRITE;
/*!40000 ALTER TABLE `biz_vendor` DISABLE KEYS */;
/*!40000 ALTER TABLE `biz_vendor` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `eap_token`
--

DROP TABLE IF EXISTS `eap_token`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `eap_token` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `host_id` int(11) NOT NULL,
  `token` varchar(64) NOT NULL,
  `layer2_encryption_mode` varchar(64) NOT NULL,
  `layer1_client_encryption_mode` varchar(64) NOT NULL,
  `layer1_appserver_encryption_mode` varchar(64) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `ix_eap_token_host_id` (`host_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `eap_token`
--

LOCK TABLES `eap_token` WRITE;
/*!40000 ALTER TABLE `eap_token` DISABLE KEYS */;
/*!40000 ALTER TABLE `eap_token` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `host`
--

DROP TABLE IF EXISTS `host`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `host` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `host_id` int(11) NOT NULL,
  `terminal_id` int(11) NOT NULL,
  `eap_license_id` int(11) NOT NULL,
  `host_type` varchar(16) DEFAULT NULL,
  `software_version` varchar(32) NOT NULL,
  `status` enum('deleted','locked','normal') NOT NULL,
  `application_id` varchar(128) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `host_id` (`host_id`),
  KEY `eap_license_id` (`eap_license_id`),
  KEY `terminal_id` (`terminal_id`),
  KEY `ix_host_host_type` (`host_type`),
  CONSTRAINT `host_ibfk_1` FOREIGN KEY (`eap_license_id`) REFERENCES `biz_product` (`id`),
  CONSTRAINT `host_ibfk_2` FOREIGN KEY (`terminal_id`) REFERENCES `terminal` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `host`
--

LOCK TABLES `host` WRITE;
/*!40000 ALTER TABLE `host` DISABLE KEYS */;
/*!40000 ALTER TABLE `host` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `host_cluster`
--

DROP TABLE IF EXISTS `host_cluster`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `host_cluster` (
  `server_id` int(11) NOT NULL,
  `cluster_id` int(11) NOT NULL,
  PRIMARY KEY (`server_id`),
  KEY `cluster_id` (`cluster_id`),
  CONSTRAINT `host_cluster_ibfk_1` FOREIGN KEY (`cluster_id`) REFERENCES `host` (`host_id`),
  CONSTRAINT `host_cluster_ibfk_2` FOREIGN KEY (`server_id`) REFERENCES `host` (`host_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `host_cluster`
--

LOCK TABLES `host_cluster` WRITE;
/*!40000 ALTER TABLE `host_cluster` DISABLE KEYS */;
/*!40000 ALTER TABLE `host_cluster` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `host_connection`
--

DROP TABLE IF EXISTS `host_connection`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `host_connection` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `client_host` int(11) NOT NULL,
  `server_host` int(11) DEFAULT NULL,
  `layer` int(11) NOT NULL,
  `conn_id` varchar(64) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `host_connection`
--

LOCK TABLES `host_connection` WRITE;
/*!40000 ALTER TABLE `host_connection` DISABLE KEYS */;
/*!40000 ALTER TABLE `host_connection` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `host_license`
--

DROP TABLE IF EXISTS `host_license`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `host_license` (
  `host_id` int(11) NOT NULL,
  `license_id` int(11) NOT NULL,
  PRIMARY KEY (`host_id`),
  KEY `license_id` (`license_id`),
  CONSTRAINT `host_license_ibfk_1` FOREIGN KEY (`host_id`) REFERENCES `host` (`host_id`),
  CONSTRAINT `host_license_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `biz_product` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `host_license`
--

LOCK TABLES `host_license` WRITE;
/*!40000 ALTER TABLE `host_license` DISABLE KEYS */;
/*!40000 ALTER TABLE `host_license` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `host_pin`
--

DROP TABLE IF EXISTS `host_pin`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `host_pin` (
  `host_id` int(11) NOT NULL,
  `pinhash_id` int(11) NOT NULL,
  PRIMARY KEY (`host_id`),
  KEY `pinhash_id` (`pinhash_id`),
  CONSTRAINT `host_pin_ibfk_1` FOREIGN KEY (`host_id`) REFERENCES `host` (`host_id`),
  CONSTRAINT `host_pin_ibfk_2` FOREIGN KEY (`pinhash_id`) REFERENCES `host_pinhash` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `host_pin`
--

LOCK TABLES `host_pin` WRITE;
/*!40000 ALTER TABLE `host_pin` DISABLE KEYS */;
/*!40000 ALTER TABLE `host_pin` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `host_pinhash`
--

DROP TABLE IF EXISTS `host_pinhash`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `host_pinhash` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `eap_license_id` int(11) NOT NULL,
  `eap_host_id` int(11) NOT NULL,
  `eap_pin_id` varchar(128) NOT NULL,
  `application_id` varchar(128) NOT NULL,
  `server_host_id` int(11) NOT NULL,
  `server_application_id` varchar(128) NOT NULL,
  `email` varchar(64) NOT NULL,
  `pin_type` varchar(64) NOT NULL,
  `pin_hash` varchar(64) NOT NULL,
  `device_serial_number` varchar(64) DEFAULT NULL,
  `status` varchar(64) NOT NULL,
  `expiration` datetime NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uc_user_app_pinhash` (`application_id`,`email`,`pin_hash`),
  KEY `eap_host_id` (`eap_host_id`),
  KEY `eap_license_id` (`eap_license_id`),
  CONSTRAINT `host_pinhash_ibfk_1` FOREIGN KEY (`eap_host_id`) REFERENCES `eap_token` (`host_id`),
  CONSTRAINT `host_pinhash_ibfk_2` FOREIGN KEY (`eap_license_id`) REFERENCES `biz_product` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `host_pinhash`
--

LOCK TABLES `host_pinhash` WRITE;
/*!40000 ALTER TABLE `host_pinhash` DISABLE KEYS */;
/*!40000 ALTER TABLE `host_pinhash` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `terminal`
--

DROP TABLE IF EXISTS `terminal`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `terminal` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `serial_number` varchar(64) NOT NULL,
  `terminal_type` varchar(32) NOT NULL,
  `global_uuid` varchar(64) NOT NULL,
  `os_type` varchar(16) NOT NULL,
  `os_version` varchar(32) NOT NULL,
  `device_model` varchar(256) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `global_uuid` (`global_uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `terminal`
--

LOCK TABLES `terminal` WRITE;
/*!40000 ALTER TABLE `terminal` DISABLE KEYS */;
/*!40000 ALTER TABLE `terminal` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2021-02-02 14:38:11
