-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
24 lines (21 loc) · 930 Bytes
/
schema.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
CREATE TABLE positions (
id SERIAL PRIMARY KEY,
user_id VARCHAR,
location geometry(POINT),
timestamp TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT unique_user_timestamp_positions UNIQUE (user_id, timestamp)
);
-- Create an index to support the unique constraint on user_id and timestamp
CREATE UNIQUE INDEX idx_unique_user_timestamp_positions ON positions (user_id, timestamp);
CREATE TABLE telemetry (
id SERIAL PRIMARY KEY,
user_id VARCHAR,
battery_level INTEGER,
voltage REAL,
timestamp TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT unique_user_timestamp_telemetry UNIQUE (user_id, timestamp)
);
-- Create an index to support the unique constraint on user_id and timestamp
CREATE UNIQUE INDEX idx_unique_user_timestamp_telemetry ON telemetry (user_id, timestamp);