OSDN Git Service

447fc8887b756d74c92be31dceb2358da38d5993
[bytom/vapor.git] / docs / federation / federation.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 /*!40000 ALTER TABLE `chains` DISABLE KEYS */;
33
34 ------------------------------------ bytom consensus --------------------------------------
35 -- chain name should be the same as BytomChainName in toolbar/federation/common/const.go --
36 -------------------------------------------------------------------------------------------
37 -- bytom mainnet consensus start--
38 -- INSERT INTO `chains`
39 -- (`id`, `name`, `block_height`, `block_hash`, `created_at`, `updated_at`)
40 -- VALUES
41 -- (1,'btm',0,'a75483474799ea1aa6bb910a1a5025b4372bf20bef20f246a2c2dc5e12e8a053','2018-09-13 05:10:43','2018-11-27 09:42:06');
42 -- bytom mainnet consensus end--
43
44 -- bytom testnet&solonet consensus start--
45 INSERT INTO `chains`
46 (`id`, `name`, `block_height`, `block_hash`, `created_at`, `updated_at`)
47 VALUES
48 (1,'btm',0,'ce4fe9431cd0225b3a811f8f8ec922f2b07a921bb12a8dddae9a85540072c770','2018-09-13 05:10:43','2018-11-27 09:42:06');
49 -- bytom testnet&solonet consensus end--
50
51
52 /*!40000 ALTER TABLE `chains` ENABLE KEYS */;
53 UNLOCK TABLES;
54
55
56 # Dump of table cross_transactions
57 # ------------------------------------------------------------
58
59 CREATE TABLE `cross_transactions` (
60   `id` int(11) NOT NULL AUTO_INCREMENT,
61   `chain_id` tinyint(1) NOT NULL,
62   `source_block_height` int(11) NOT NULL,
63   `source_block_timestamp` int(11) NOT NULL,
64   `source_block_hash` char(64) NOT NULL,
65   `source_tx_index` int(11) NOT NULL,
66   `source_mux_id` char(64) NOT NULL,
67   `source_tx_hash` char(64) NOT NULL,
68   `source_raw_transaction` mediumtext NOT NULL,
69   `dest_block_height` int(11) DEFAULT NULL,
70   `dest_block_timestamp` int(11) DEFAULT NULL,
71   `dest_block_hash` char(64) DEFAULT NULL,
72   `dest_tx_index` int(11) DEFAULT NULL,
73   `dest_tx_hash` char(64) DEFAULT NULL,
74   `status` tinyint(1) DEFAULT '0',
75   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
76   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
77   PRIMARY KEY (`id`),
78   UNIQUE KEY `source_mux_id` (`chain_id`,`source_mux_id`),
79   UNIQUE KEY `source_tx_hash` (`chain_id`,`source_tx_hash`),
80   UNIQUE KEY `source_blockhash_txidx` (`chain_id`,`source_block_hash`,`source_tx_index`),
81   UNIQUE KEY `source_blockheight_txidx` (`chain_id`,`source_block_height`,`source_tx_index`),
82   UNIQUE KEY `dest_tx_hash` (`chain_id`,`dest_tx_hash`),
83   UNIQUE KEY `dest_blockhash_txidx` (`chain_id`,`dest_block_hash`,`dest_tx_index`),
84   UNIQUE KEY `dest_blockheight_txidx` (`chain_id`,`dest_block_height`,`dest_tx_index`),
85   CONSTRAINT `cross_transactions_ibfk_1` FOREIGN KEY (`chain_id`) REFERENCES `chains` (`id`)
86 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
87
88 LOCK TABLES `cross_transactions` WRITE;
89 UNLOCK TABLES;
90
91
92 # Dump of table cross_transaction_reqs
93 # ------------------------------------------------------------
94 CREATE TABLE `cross_transaction_reqs` (
95   `id` int(11) NOT NULL AUTO_INCREMENT,
96   `cross_transaction_id` int(11) NOT NULL,
97   `source_pos` int(11) NOT NULL,
98   `asset_id` int(11) NOT NULL,
99   `asset_amount` bigint(20) DEFAULT '0',
100   `script` varchar(128) NOT NULL,
101   `from_address` varchar(128) NOT NULL DEFAULT '',
102   `to_address` varchar(128) NOT NULL DEFAULT '',
103   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
104   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
105   PRIMARY KEY (`id`),
106   UNIQUE KEY `req_id` (`cross_transaction_id`,`source_pos`),
107   CONSTRAINT `cross_transaction_reqs_ibfk_1` FOREIGN KEY (`cross_transaction_id`) REFERENCES `cross_transactions` (`id`),
108   CONSTRAINT `cross_transaction_reqs_ibfk_2` FOREIGN KEY (`asset_id`) REFERENCES `assets` (`id`)
109 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
110
111 LOCK TABLES `cross_transaction_reqs` WRITE;
112 UNLOCK TABLES;
113
114
115 # Dump of table assets
116 # ------------------------------------------------------------
117
118 CREATE TABLE `assets` (
119   `id` int(11) NOT NULL AUTO_INCREMENT,
120   `asset_id` varchar(64) NOT NULL,
121   `issuance_program` varchar(128) NOT NULL,
122   `vm_version` int(11) NOT NULL DEFAULT '1',
123   `definition` text,
124   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
125   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
126   PRIMARY KEY (`id`),
127   UNIQUE KEY `asset_id` (`asset_id`)
128 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
129
130 LOCK TABLES `assets` WRITE;
131 /*!40000 ALTER TABLE `assets` DISABLE KEYS */;
132
133 INSERT INTO `assets` (`id`, `asset_id`, `issuance_program`, `vm_version`, `definition`, `created_at`, `updated_at`)
134 VALUES
135   (1,'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff','',1,
136   '{
137     "decimals": 8,
138     "description": "Bytom Official Issue",
139     "name": "BTM",
140     "symbol": "BTM"
141   }',
142   '2018-09-13 05:10:43','2018-11-27 09:43:35');
143
144 /*!40000 ALTER TABLE `assets` ENABLE KEYS */;
145 UNLOCK TABLES;