OSDN Git Service

rename node.host to node.ip
[bytom/vapor.git] / docs / precog / sql_dump / precog_schema.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 CREATE SCHEMA IF NOT EXISTS `precog`;
10 DROP DATABASE `precog`;
11 CREATE SCHEMA `precog`;
12
13 USE `precog`;
14
15 # Dump of table nodes
16 # ------------------------------------------------------------
17
18 CREATE TABLE `nodes` (
19   `id` int(11) NOT NULL AUTO_INCREMENT,
20   `alias` varchar(128) NOT NULL DEFAULT '',
21   `xpub` char(128) NOT NULL DEFAULT '',
22   `public_key` char(64) NOT NULL DEFAULT '',
23   `ip` varchar(128) NOT NULL DEFAULT '',
24   `port` smallint unsigned NOT NULL DEFAULT '0',
25   `best_height` int(11) DEFAULT '0',
26   `latest_daily_uptime_minutes` int(11) DEFAULT '0',
27   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
28   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
29   PRIMARY KEY (`id`),
30   UNIQUE KEY `public_key` (`public_key`)
31 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
32
33 LOCK TABLES `nodes` WRITE;
34 UNLOCK TABLES;
35
36
37 # Dump of table node_livenesses
38 # ------------------------------------------------------------
39
40 CREATE TABLE `node_livenesses` (
41   `id` int(11) NOT NULL AUTO_INCREMENT,
42   `node_id` int(11) NOT NULL,
43   `ping_times` int(11) DEFAULT '0',
44   `pong_times` int(11) DEFAULT '0',
45   `avg_lantency_ms` int(11) DEFAULT NULL,
46   `best_height` int(11) DEFAULT '0',
47   `status` tinyint(1) NOT NULL DEFAULT '0',
48   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
49   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
50   PRIMARY KEY (`id`),
51   CONSTRAINT `node_livenesses_ibfk_1` FOREIGN KEY (`node_id`) REFERENCES `nodes` (`id`)
52 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
53
54 LOCK TABLES `node_livenesses` WRITE;
55 UNLOCK TABLES;
56