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 */;
9 DROP DATABASE `federation`;
11 CREATE SCHEMA IF NOT EXISTS `federation`;
16 # Dump of table chains
17 # ------------------------------------------------------------
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,
27 UNIQUE KEY `name` (`name`),
28 UNIQUE KEY `block_hash` (`id`,`block_hash`)
29 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31 LOCK TABLES `chains` WRITE;
35 # Dump of table cross_transactions
36 # ------------------------------------------------------------
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,
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;
67 LOCK TABLES `cross_transactions` WRITE;
71 # Dump of table cross_transaction_reqs
72 # ------------------------------------------------------------
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,
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;
91 LOCK TABLES `cross_transaction_reqs` WRITE;
95 # Dump of table assets
96 # ------------------------------------------------------------
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',
104 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
105 `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
107 UNIQUE KEY `asset_id` (`asset_id`)
108 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
110 LOCK TABLES `assets` WRITE;