-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathlibsql.sql
More file actions
39 lines (34 loc) · 1.26 KB
/
libsql.sql
File metadata and controls
39 lines (34 loc) · 1.26 KB
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
/* In SQLite, we store time as an 8-byte integer (i64) with microsecond precision. This matches TIMESTAMPTZ in Postgres.
Use `chrono::DateTime::timestamp_micros` when inserting or fetching timestamps in Rust.
*/
CREATE TABLE IF NOT EXISTS version
(
version integer PRIMARY KEY,
updated_at integer NOT NULL DEFAULT (
CAST(strftime('%s', 'now') AS integer) * 1000000 + CAST(strftime('%f', 'now') * 1000000 AS integer) % 1000000
)
);
CREATE TABLE IF NOT EXISTS run
(
id integer PRIMARY KEY AUTOINCREMENT,
start_time integer NOT NULL DEFAULT (
CAST(strftime('%s', 'now') AS integer) * 1000000 + CAST(strftime('%f', 'now') * 1000000 AS integer) % 1000000
),
pipe_name text NOT NULL
);
CREATE TABLE IF NOT EXISTS http_request
(
id integer PRIMARY KEY,
at integer NOT NULL DEFAULT (
CAST(strftime('%s', 'now') AS integer) * 1000000 + CAST(strftime('%f', 'now') * 1000000 AS integer) % 1000000
),
method text NOT NULL,
path text NOT NULL,
status_code integer NOT NULL
);
CREATE TABLE IF NOT EXISTS elevate_tmp_request
(
req_id integer PRIMARY KEY,
seconds integer NOT NULL
);
INSERT INTO version (version) VALUES (1) ON CONFLICT DO NOTHING;