-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcommon_trace_index.nim
62 lines (57 loc) · 1.8 KB
/
common_trace_index.nim
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
# backend agnostic code, part of the trace_index module, should not be imported directly,
# use common/trace_index or frontend/trace_index instead.
type
CodetracerNotImplementedError* = object of ValueError
const NO_TRACE_ID* = -1
### FREEZE for now the state of those
### schemas
### TODO:
### eventually add ALTER statements
### when we add new fields
### as a minimal form of auto-migration
### or implement a more advanced form of
### migration logic/refactoring
### (idea by Nikola)
### important: must keep in mind we
### use indices for native nim
### db row field extraction
### so if we add/remove fields
### we must update them accordingly
const SQL_CREATE_TABLE_STATEMENTS = @[
"""CREATE TABLE IF NOT EXISTS traces (
id integer,
program text,
args text,
compileCommand text,
env text,
workdir text,
output text,
sourceFolders text,
lowLevelFolder text,
outputFolder text,
lang integer,
imported integer,
shellID integer,
rrPid integer,
exitCode integer,
calltrace integer,
calltraceMode string,
date text);""",
"""CREATE TABLE IF NOT EXISTS trace_values (
id integer,
maxTraceID integer,
UNIQUE(id));""",
"""CREATE TABLE IF NOT EXISTS record_pid_trace_id_map (
pid integer,
traceId integer);""",
]
const SQL_INITIAL_INSERT_STATEMENTS = @[
"""INSERT INTO trace_values (id, maxTraceID) VALUES (0, 0)""",
]
const SQL_ALTER_TABLE_STATEMENTS: seq[string] = @[
# example: adding a new column
"""ALTER TABLE traces ADD COLUMN remoteShareDownloadId text;""",
"""ALTER TABLE traces ADD COLUMN remoteShareControlId text;""",
"""ALTER TABLE traces ADD COLUMN remoteShareExpireTime INTEGER DEFAULT -1;"""
# """ALTER TABLE traces ADD COLUMN love integer;"""
]