OSDN Git Service

946f10c9c2cf175ff712fe75c071ae01673e39d0
[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   KEY `chain_id` (`chain_id`),
58   UNIQUE KEY `source_tx_hash` (`source_tx_hash`),
59   UNIQUE KEY `dest_tx_hash` (`dest_tx_hash`),
60   CONSTRAINT `cross_transactions_ibfk_1` FOREIGN KEY (`chain_id`) REFERENCES `chains` (`id`)
61 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
62
63 LOCK TABLES `cross_transactions` WRITE;
64 UNLOCK TABLES;
65
66
67 # Dump of table cross_transaction_reqs
68 # ------------------------------------------------------------
69
70 CREATE TABLE `cross_transaction_reqs` (
71   `id` int(11) NOT NULL AUTO_INCREMENT,
72   `cross_transaction_id` int(11) NOT NULL,
73   `source_pos` int(11) NOT NULL,
74   `asset_id` int(11) NOT NULL,
75   `asset_amount` bigint(20) DEFAULT '0',
76   `script` varchar(128) NOT NULL,
77   `from_address` varchar(128) NOT NULL DEFAULT '',
78   `to_address` varchar(128) NOT NULL DEFAULT '',
79   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
80   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
81   PRIMARY KEY (`id`),
82   CONSTRAINT `cross_transaction_reqs_ibfk_1` FOREIGN KEY (`cross_transaction_id`) REFERENCES `cross_transactions` (`id`),
83   CONSTRAINT `cross_transaction_reqs_ibfk_2` FOREIGN KEY (`asset_id`) REFERENCES `assets` (`id`)
84 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
85
86 LOCK TABLES `cross_transaction_reqs` WRITE;
87 UNLOCK TABLES;
88
89
90 # Dump of table assets
91 # ------------------------------------------------------------
92
93 CREATE TABLE `assets` (
94   `id` int(11) NOT NULL AUTO_INCREMENT,
95   `asset_id` varchar(64) NOT NULL,
96   `issuance_program` varchar(128) NOT NULL,
97   `vm_version` int(11) NOT NULL DEFAULT '1',
98   `definition` text,
99   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
100   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
101   PRIMARY KEY (`id`),
102   UNIQUE KEY `asset_id` (`asset_id`)
103 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
104
105 LOCK TABLES `assets` WRITE;
106 UNLOCK TABLES;