-
Notifications
You must be signed in to change notification settings - Fork 13
/
db_mysql.sql
65 lines (60 loc) · 1.95 KB
/
db_mysql.sql
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
62
63
64
65
CREATE TABLE IF NOT EXISTS carStatus (
time TIMESTAMP NOT NULL PRIMARY KEY,
batterySOC decimal(3, 0),
remainingRange smallint,
remainingChargingTime smallint,
chargeState text,
chargePower decimal(4, 1),
chargeRateKMPH smallint,
maxChargeCurrentAC text,
autoUnlockPlugWhenCharged text,
targetSOC decimal(3, 0),
plugConnectionState text,
plugLockState text,
remainClimatisationTime smallint,
hvacState text,
hvacTargetTemp decimal(3, 1),
hvacWithoutExternalPower boolean,
hvacAtUnlock boolean,
windowHeatingEnabled boolean,
zoneFrontLeftEnabled boolean,
zoneFrontRightEnabled boolean,
zoneRearLeftEnabled boolean,
zoneRearRightEnabled boolean,
frontWindowHeatingState text,
rearWindowHeatingState text,
odometer integer
);
CREATE TABLE IF NOT EXISTS users (
userid serial NOT NULL PRIMARY KEY,
username varchar(64) UNIQUE NOT NULL,
hash text NOT NULL
);
CREATE TABLE IF NOT EXISTS authKeys (
authKey text UNIQUE NOT NULL
);
CREATE TABLE IF NOT EXISTS carPictures (
pictureID varchar(128) NOT NULL PRIMARY KEY,
carPicture mediumtext NOT NULL
);
CREATE TABLE IF NOT EXISTS chargingSessions (
sessionid serial UNIQUE NOT NULL,
startTime TIMESTAMP NOT NULL PRIMARY KEY,
endTime TIMESTAMP NULL,
chargeStartTime TIMESTAMP NULL,
chargeEndTime TIMESTAMP NULL,
duration integer,
avgChargePower decimal(4, 1),
maxChargePower decimal(4, 1),
minChargePower decimal(4, 1),
chargeEnergy float4,
rangeStart smallint,
rangeEnd smallint,
targetSOC smallint,
socStart decimal(3, 0),
socEnd decimal(3, 0)
);
CREATE TABLE IF NOT EXISTS settings (
settingKey varchar(128) NOT NULL PRIMARY KEY,
settingValue mediumtext
)