forked from chriseng/nestgraph
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dbsetup
61 lines (57 loc) · 2.17 KB
/
dbsetup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
CREATE DATABASE nest;
GRANT ALL PRIVILEGES ON nest.* TO 'nest_admin'@'localhost' IDENTIFIED BY 'choose_a_db_password';
FLUSH PRIVILEGES;
USE nest;
CREATE TABLE `data` (
`timestamp` timestamp NOT NULL,
`heating` tinyint unsigned NOT NULL,
`cooling` tinyint unsigned NOT NULL,
`fan` tinyint unsigned NOT NULL,
`autoAway` tinyint signed NOT NULL,
`manualAway` tinyint unsigned NOT NULL,
`leaf` tinyint unsigned NOT NULL,
`target` numeric(7,3) NOT NULL,
`current` numeric(7,3) NOT NULL,
`humidity` tinyint unsigned NOT NULL,
`updated` timestamp NOT NULL,
PRIMARY KEY (`timestamp`),
UNIQUE KEY `timestamp` (`timestamp`)
)ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `nest`.`cycles_data` (
`cycleNum` int(10) unsigned NOT NULL,
`cycleDate` datetime NOT NULL,
`start` int(10) unsigned NOT NULL,
`duration` int(10) unsigned NOT NULL,
`type` int(10) unsigned NOT NULL,
PRIMARY KEY (`cycleNum`,`cycleDate`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `nest`.`energy_data` (
`energyDate` datetime NOT NULL,
`device_timezone_offset` int(11) NOT NULL,
`total_heating_time` int(10) unsigned NOT NULL,
`total_cooling_time` int(10) unsigned NOT NULL,
`total_fan_cooling_time` int(10) unsigned NOT NULL,
`total_humidifier_time` int(10) unsigned NOT NULL,
`total_dehumidifier_time` int(10) unsigned NOT NULL,
`leafs` int(11) NOT NULL,
`whodunit` int(11) NOT NULL,
`recent_avg_used` int(10) unsigned NOT NULL,
`usage_over_avg` int(10) NOT NULL,
PRIMARY KEY (`energyDate`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `nest`.`events_data` (
`eventNum` int(10) unsigned NOT NULL,
`eventDate` datetime NOT NULL,
`start` int(10) unsigned NOT NULL,
`end` int(10) unsigned NOT NULL,
`type` int(10) unsigned NOT NULL,
`touched_by` int(10) unsigned NOT NULL,
`touched_when` int(10) unsigned NOT NULL,
`touched_timezone_offset` int(11) NOT NULL,
`touched_where` int(11) NOT NULL,
`heat_temp` int(11) NOT NULL,
`cool_temp` int(11) NOT NULL,
`continuation` int(11) NOT NULL,
`event_touched_by` int(11) NOT NULL,
PRIMARY KEY (`eventNum`,`eventDate`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;