OSDN Git Service

feat(federation): add mainchain & sidechain listener (#170)
[bytom/vapor.git] / docs / federation / federation.sql
index 1d6f894..b2613c5 100644 (file)
@@ -6,6 +6,8 @@
 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
 
+DROP DATABASE `federation`;
+
 CREATE SCHEMA IF NOT EXISTS `federation`;
 
 USE `federation`;
@@ -13,10 +15,8 @@ USE `federation`;
 # Dump of table warders
 # ------------------------------------------------------------
 
-DROP TABLE IF EXISTS `warders`;
-
 CREATE TABLE `warders` (
-  `id` tinyint(1) unsigned NOT NULL AUTO_INCREMENT,
+  `id` tinyint(1) NOT NULL AUTO_INCREMENT,
   `pubkey` varchar(64) NOT NULL,
   `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
   `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@@ -60,7 +60,7 @@ UNLOCK TABLES;
 
 CREATE TABLE `cross_transactions` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
-  `chain_id` int(11) NOT NULL,
+  `chain_id` tinyint(1) NOT NULL,
   `source_block_height` int(11) NOT NULL,
   `source_block_hash` char(64) NOT NULL,
   `source_tx_index` int(11) NOT NULL,
@@ -77,12 +77,11 @@ CREATE TABLE `cross_transactions` (
   PRIMARY KEY (`id`),
   UNIQUE KEY `source_mux_id` (`chain_id`,`source_mux_id`),
   UNIQUE KEY `source_tx_hash` (`chain_id`,`source_tx_hash`),
-  UNIQUE KEY `source_raw_transaction` (`source_raw_transaction`),
-  UNIQUE KEY `source_blockhash_txidx` (`chain_id`,`source_block_hash`,`tx_index`),
-  UNIQUE KEY `source_blockheight_txidx` (`chain_id`,`source_block_height`,`tx_index`),
+  UNIQUE KEY `source_blockhash_txidx` (`chain_id`,`source_block_hash`,`source_tx_index`),
+  UNIQUE KEY `source_blockheight_txidx` (`chain_id`,`source_block_height`,`source_tx_index`),
   UNIQUE KEY `dest_tx_hash` (`chain_id`,`dest_tx_hash`),
-  UNIQUE KEY `dest_blockhash_txidx` (`chain_id`,`dest_block_hash`,`tx_index`),
-  UNIQUE KEY `dest_blockheight_txidx` (`chain_id`,`dest_block_height`,`tx_index`),
+  UNIQUE KEY `dest_blockhash_txidx` (`chain_id`,`dest_block_hash`,`dest_tx_index`),
+  UNIQUE KEY `dest_blockheight_txidx` (`chain_id`,`dest_block_height`,`dest_tx_index`),
   CONSTRAINT `cross_transactions_ibfk_1` FOREIGN KEY (`chain_id`) REFERENCES `chains` (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -116,7 +115,7 @@ UNLOCK TABLES;
 CREATE TABLE `cross_transaction_signs` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `cross_transaction_id` int(11) NOT NULL,
-  `warder_id` int(11) NOT NULL,
+  `warder_id` tinyint(1) NOT NULL,
   `signatures` text NOT NULL,
   `status` tinyint(1) NOT NULL,
   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -134,8 +133,6 @@ UNLOCK TABLES;
 # Dump of table assets
 # ------------------------------------------------------------
 
-DROP TABLE IF EXISTS `assets`;
-
 CREATE TABLE `assets` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `asset_id` varchar(64) NOT NULL,
@@ -145,8 +142,7 @@ CREATE TABLE `assets` (
   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
   PRIMARY KEY (`id`),
-  UNIQUE KEY `asset_id` (`asset_id`),
-  UNIQUE KEY `asset_meta` (`issuance_program`,`vm_version`,`raw_definition_byte`)
+  UNIQUE KEY `asset_id` (`asset_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 LOCK TABLES `assets` WRITE;