2 -- FIXME: FOREIGN keys are now supported. schema should enforces them.
3 -- Right now the support here is disabled.
5 DROP TABLE IF EXISTS workspace;
6 CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT,
7 workspace_name text not null unique,
11 DROP TABLE IF EXISTS project;
12 CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
13 project_name text not null,
14 project_version text not null default '1.0',
15 wrkspace_id integer REFERENCES workspace (workspace_id),
17 unique (project_name, project_version)
20 DROP TABLE IF EXISTS file;
21 CREATE TABLE file (file_id integer PRIMARY KEY AUTOINCREMENT,
22 file_path text not null unique,
23 prj_id integer REFERENCES project (projec_id),
24 lang_id integer REFERENCES language (language_id),
28 DROP TABLE IF EXISTS language;
29 CREATE TABLE language (language_id integer PRIMARY KEY AUTOINCREMENT,
30 language_name text not null unique);
32 DROP TABLE IF EXISTS symbol;
33 CREATE TABLE symbol (symbol_id integer PRIMARY KEY AUTOINCREMENT,
34 file_defined_id integer not null REFERENCES file (file_id),
36 file_position integer,
37 is_file_scope integer,
40 scope_definition_id integer,
42 type_type text not null,
43 type_name text not null,
44 kind_id integer REFERENCES sym_kind (sym_kind_id),
45 access_kind_id integer REFERENCES sym_access (sym_access_id),
46 implementation_kind_id integer REFERENCES sym_implementation (sym_impl_id),
47 update_flag integer default 0,
48 unique (name, file_defined_id, file_position, update_flag)
51 DROP TABLE IF EXISTS sym_kind;
52 CREATE TABLE sym_kind (sym_kind_id integer PRIMARY KEY AUTOINCREMENT,
53 kind_name text not null unique,
54 is_container integer default 0
57 DROP TABLE IF EXISTS sym_access;
58 CREATE TABLE sym_access (access_kind_id integer PRIMARY KEY AUTOINCREMENT,
59 access_name text not null unique
62 DROP TABLE IF EXISTS sym_implementation;
63 CREATE TABLE sym_implementation (sym_impl_id integer PRIMARY KEY AUTOINCREMENT,
64 implementation_name text not null unique
67 DROP TABLE IF EXISTS heritage;
68 CREATE TABLE heritage (symbol_id_base integer REFERENCES symbol (symbol_id),
69 symbol_id_derived integer REFERENCES symbol (symbol_id),
70 PRIMARY KEY (symbol_id_base, symbol_id_derived)
73 DROP TABLE IF EXISTS scope;
74 CREATE TABLE scope (scope_id integer PRIMARY KEY AUTOINCREMENT,
75 scope_name text not null,
79 DROP TABLE IF EXISTS version;
80 CREATE TABLE version (sdb_version numeric PRIMARY KEY);
83 DROP TABLE IF EXISTS __tmp_removed;
84 CREATE TABLE __tmp_removed (tmp_removed_id integer PRIMARY KEY AUTOINCREMENT,
85 symbol_removed_id integer not null
89 DROP INDEX IF EXISTS symbol_idx_1;
90 CREATE INDEX symbol_idx_1 ON symbol (name, file_defined_id, type_type, type_name);
92 -- removing this index isn't worth because the performance gain is invisible.
93 DROP INDEX IF EXISTS symbol_idx_2;
94 CREATE INDEX symbol_idx_2 ON symbol (scope_id);
96 -- removing this index isn't worth because the performance gain is invisible.
97 DROP INDEX IF EXISTS symbol_idx_3;
98 CREATE INDEX symbol_idx_3 ON symbol (type_type, type_name);
101 DROP TRIGGER IF EXISTS delete_file_trg;
102 CREATE TRIGGER delete_file_trg BEFORE DELETE ON file
105 DELETE FROM symbol WHERE file_defined_id = old.file_id;
108 DROP TRIGGER IF EXISTS delete_symbol_trg;
109 CREATE TRIGGER delete_symbol_trg BEFORE DELETE ON symbol
112 DELETE FROM scope WHERE scope.scope_id=old.scope_definition_id;
113 UPDATE symbol SET scope_id='-1' WHERE symbol.scope_id=old.scope_definition_id AND symbol.scope_id > 0;
114 INSERT INTO __tmp_removed (symbol_removed_id) VALUES (old.symbol_id);
117 PRAGMA page_size = 32768;
118 PRAGMA cache_size = 12288;
119 PRAGMA synchronous = OFF;
120 PRAGMA temp_store = MEMORY;
121 PRAGMA case_sensitive_like = 1;
122 PRAGMA journal_mode = OFF;
123 PRAGMA read_uncommitted = 1;
124 PRAGMA foreign_keys = OFF;
125 PRAGMA auto_vacuum = 0;