OSDN Git Service

update (#333)
[bytom/vapor.git] / docs / federation / sql_dump / federation_shema.sql
1 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
2 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
3 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
4 /*!40101 SET NAMES utf8 */;
5 /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
6 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
7 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
8
9 DROP DATABASE `federation`;
10
11 CREATE SCHEMA IF NOT EXISTS `federation`;
12
13 USE `federation`;
14
15
16 # Dump of table chains
17 # ------------------------------------------------------------
18
19 CREATE TABLE `chains` (
20   `id` tinyint(1) NOT NULL AUTO_INCREMENT,
21   `name` varchar(64) NOT NULL,
22   `block_height` int(11) DEFAULT '0',
23   `block_hash` char(64) NOT NULL,
24   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
25   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
26   PRIMARY KEY (`id`),
27   UNIQUE KEY `name` (`name`),
28   UNIQUE KEY `block_hash` (`id`,`block_hash`)
29 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
30
31 LOCK TABLES `chains` WRITE;
32 UNLOCK TABLES;
33
34
35 # Dump of table cross_transactions
36 # ------------------------------------------------------------
37
38 CREATE TABLE `cross_transactions` (
39   `id` int(11) NOT NULL AUTO_INCREMENT,
40   `chain_id` tinyint(1) NOT NULL,
41   `source_block_height` int(11) NOT NULL,
42   `source_block_timestamp` int(11) NOT NULL,
43   `source_block_hash` char(64) NOT NULL,
44   `source_tx_index` int(11) NOT NULL,
45   `source_mux_id` char(64) NOT NULL,
46   `source_tx_hash` char(64) NOT NULL,
47   `source_raw_transaction` mediumtext NOT NULL,
48   `dest_block_height` int(11) DEFAULT NULL,
49   `dest_block_timestamp` int(11) DEFAULT NULL,
50   `dest_block_hash` char(64) DEFAULT NULL,
51   `dest_tx_index` int(11) DEFAULT NULL,
52   `dest_tx_hash` char(64) DEFAULT NULL,
53   `status` tinyint(1) DEFAULT '0',
54   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
55   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
56   PRIMARY KEY (`id`),
57   UNIQUE KEY `source_mux_id` (`chain_id`,`source_mux_id`),
58   UNIQUE KEY `source_tx_hash` (`chain_id`,`source_tx_hash`),
59   UNIQUE KEY `source_blockhash_txidx` (`chain_id`,`source_block_hash`,`source_tx_index`),
60   UNIQUE KEY `source_blockheight_txidx` (`chain_id`,`source_block_height`,`source_tx_index`),
61   UNIQUE KEY `dest_tx_hash` (`chain_id`,`dest_tx_hash`),
62   UNIQUE KEY `dest_blockhash_txidx` (`chain_id`,`dest_block_hash`,`dest_tx_index`),
63   UNIQUE KEY `dest_blockheight_txidx` (`chain_id`,`dest_block_height`,`dest_tx_index`),
64   CONSTRAINT `cross_transactions_ibfk_1` FOREIGN KEY (`chain_id`) REFERENCES `chains` (`id`)
65 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
66
67 LOCK TABLES `cross_transactions` WRITE;
68 UNLOCK TABLES;
69
70
71 # Dump of table cross_transaction_reqs
72 # ------------------------------------------------------------
73
74 CREATE TABLE `cross_transaction_reqs` (
75   `id` int(11) NOT NULL AUTO_INCREMENT,
76   `cross_transaction_id` int(11) NOT NULL,
77   `source_pos` int(11) NOT NULL,
78   `asset_id` int(11) NOT NULL,
79   `asset_amount` bigint(20) DEFAULT '0',
80   `script` varchar(128) NOT NULL,
81   `from_address` varchar(128) NOT NULL DEFAULT '',
82   `to_address` varchar(128) NOT NULL DEFAULT '',
83   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
84   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
85   PRIMARY KEY (`id`),
86   UNIQUE KEY `req_id` (`cross_transaction_id`,`source_pos`),
87   CONSTRAINT `cross_transaction_reqs_ibfk_1` FOREIGN KEY (`cross_transaction_id`) REFERENCES `cross_transactions` (`id`),
88   CONSTRAINT `cross_transaction_reqs_ibfk_2` FOREIGN KEY (`asset_id`) REFERENCES `assets` (`id`)
89 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
90
91 LOCK TABLES `cross_transaction_reqs` WRITE;
92 UNLOCK TABLES;
93
94
95 # Dump of table assets
96 # ------------------------------------------------------------
97
98 CREATE TABLE `assets` (
99   `id` int(11) NOT NULL AUTO_INCREMENT,
100   `asset_id` varchar(64) NOT NULL,
101   `issuance_program` varchar(128) NOT NULL,
102   `vm_version` int(11) NOT NULL DEFAULT '1',
103   `definition` text,
104   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
105   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
106   PRIMARY KEY (`id`),
107   UNIQUE KEY `asset_id` (`asset_id`)
108 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
109
110 LOCK TABLES `assets` WRITE;
111 UNLOCK TABLES;