-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb.sql
More file actions
30 lines (26 loc) · 706 Bytes
/
db.sql
File metadata and controls
30 lines (26 loc) · 706 Bytes
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
CREATE TABLE IF NOT EXISTS start
(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
value VARCHAR(255) UNIQUE
);
CREATE TABLE IF NOT EXISTS end
(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
value VARCHAR(255) UNIQUE
);
CREATE TABLE IF NOT EXISTS sequences
(
start_id INTEGER NOT NULL,
end_id INTEGER NOT NULL,
next_value INTEGER NOT NULL DEFAULT (ABS(RANDOM() % 10000)),
count INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (start_id, end_id)
);
CREATE TABLE IF NOT EXISTS state
(
current_count INTEGER NOT NULL DEFAULT 0,
next_start_id INTEGER NOT NULL DEFAULT 1,
next_end_id INTEGER NOT NULL DEFAULT 1
);
INSERT INTO state DEFAULT
VALUES;