-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path20160610_2106_install_schema.sql
150 lines (134 loc) · 5.02 KB
/
20160610_2106_install_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
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
-- The "Files" table
CREATE TABLE "Files" (
"Id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"Name" text NOT NULL,
"Size" integer NOT NULL,
"Found" integer NOT NULL DEFAULT 1
);
CREATE INDEX "IDX_FILES_FOUND" ON Files ("Found");
-- The "Functions" table
CREATE TABLE "Functions" (
"Id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"FileId" integer NOT NULL,
"Name" text NOT NULL,
"ParameterCount" integer NOT NULL DEFAULT 0,
"RequiredParameterCount" integer NOT NULL DEFAULT 0,
"IsVariadic" integer NOT NULL DEFAULT 0,
"ReturnsReference" integer NOT NULL DEFAULT 0,
"HasReturnType" integer NOT NULL DEFAULT 0,
"ReturnType" text,
CONSTRAINT "FK_FUNCTIONS_FILEID" FOREIGN KEY ("FileId") REFERENCES "Files" ("Id")
);
CREATE UNIQUE INDEX "IDX_FUNCTIONS_FUNCTION" ON Functions ("FileId" ASC, "Name" ASC);
-- The "FunctionParameters" table
CREATE TABLE "FunctionParameters" (
"FunctionId" integer NOT NULL,
"Name" text NOT NULL,
"Position" integer,
"TypeClass" text,
"HasType" integer NOT NULL DEFAULT 0,
"TypeName" text,
"AllowsNull" integer NOT NULL DEFAULT 0,
"IsArray" integer NOT NULL DEFAULT 0,
"IsCallable" integer NOT NULL DEFAULT 0,
"IsOptional" integer NOT NULL DEFAULT 0,
"IsVariadic" integer NOT NULL DEFAULT 0,
"CanBePassedByValue" integer NOT NULL DEFAULT 0,
"IsPassedByReference" integer NOT NULL DEFAULT 0,
"HasDefaultValue" integer NOT NULL DEFAULT 0,
"DefaultValue" text,
"DefaultConstant" text,
PRIMARY KEY("FunctionId","Name"),
CONSTRAINT "FK_FUNCTIONPARAMETERS_FUNCTIONID" FOREIGN KEY ("FunctionId") REFERENCES "Functions" ("Id")
);
CREATE UNIQUE INDEX "IDX_FUNCTIONPARAMETERS_NAME" ON FunctionParameters ("FunctionId", "Name");
-- The "Constants" table
CREATE TABLE "Constants" (
"FileId" integer NOT NULL,
"Name" text NOT NULL,
"Value" text,
PRIMARY KEY("FileId","Name"),
CONSTRAINT "FK_CONSTANTS_FILEID" FOREIGN KEY ("FileId") REFERENCES "Files" ("Id")
);
-- The "Classes" table
CREATE TABLE "Classes" (
"Id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"FileId" integer NOT NULL,
"Name" text NOT NULL,
"ClassType" integer NOT NULL,
"IsAbstract" integer NOT NULL DEFAULT 0,
"IsFinal" integer NOT NULL DEFAULT 0,
"RawRelations" text,
CONSTRAINT "FK_CLASSES_FILEID" FOREIGN KEY ("FileId") REFERENCES "Files" ("Id")
);
CREATE UNIQUE INDEX "IDX_CLASSES_CLASS" ON Classes ("Name" ASC, "FileId" ASC);
CREATE INDEX "IDX_CLASSES_FILEID" ON Classes ("FileId");
-- The "ClassRelations" table
CREATE TABLE "ClassRelations" (
"ClassId" integer NOT NULL,
"RelatedClass" text NOT NULL,
"RelatedClassId" integer NOT NULL,
"RelationType" integer NOT NULL,
PRIMARY KEY("ClassId","RelatedClass","RelatedClassId"),
CONSTRAINT "FK_CLASSRELATIONS_CLASSID" FOREIGN KEY ("ClassId") REFERENCES "Classes" ("Id"),
CONSTRAINT "FK_CLASSRELATIONS_RELATEDCLASSID" FOREIGN KEY ("RelatedClassId") REFERENCES "Classes" ("Id")
);
-- The "ClassConstants" table
CREATE TABLE "ClassConstants" (
"ClassId" integer NOT NULL,
"Name" text NOT NULL,
"Value" text,
PRIMARY KEY("ClassId","Name"),
CONSTRAINT "FK_CLASSCONSTANTS_CLASSID" FOREIGN KEY ("ClassId") REFERENCES "Classes" ("Id")
);
-- The "ClassProperties" table
CREATE TABLE "ClassProperties" (
"ClassId" integer NOT NULL,
"Name" text NOT NULL,
"Value" text,
"Scope" integer NOT NULL,
"IsStatic" integer NOT NULL DEFAULT 0,
PRIMARY KEY("ClassId","Name"),
CONSTRAINT "FK_CLASSPROPERTIES_CLASSID" FOREIGN KEY ("ClassId") REFERENCES "Classes" ("Id")
);
CREATE UNIQUE INDEX "IDX_CLASSPROPERTIES_NAME" ON ClassProperties ("ClassId", "Name");
-- The "ClassMethods" table
CREATE TABLE "ClassMethods" (
"Id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"ClassId" integer NOT NULL,
"Name" text NOT NULL,
"ParameterCount" integer NOT NULL DEFAULT 0,
"RequiredParameterCount" integer NOT NULL DEFAULT 0,
"Scope" integer NOT NULL,
"IsAbstract" integer NOT NULL DEFAULT 0,
"IsFinal" integer NOT NULL DEFAULT 0,
"IsStatic" integer NOT NULL DEFAULT 0,
"IsVariadic" integer NOT NULL DEFAULT 0,
"ReturnsReference" integer NOT NULL DEFAULT 0,
"HasReturnType" integer NOT NULL DEFAULT 0,
"ReturnType" text,
CONSTRAINT "FK_CLASSMETHODS_CLASSID" FOREIGN KEY ("ClassId") REFERENCES "Classes" ("Id")
);
CREATE UNIQUE INDEX "IDX_CLASSMETHODS_METHOD" ON ClassMethods ("ClassId" ASC, "Name" ASC);
-- The "MethodParameters" table
CREATE TABLE "MethodParameters" (
"MethodId" integer NOT NULL,
"Name" text NOT NULL,
"Position" integer,
"TypeClass" text,
"HasType" integer NOT NULL DEFAULT 0,
"TypeName" text,
"AllowsNull" integer NOT NULL DEFAULT 0,
"IsArray" integer NOT NULL DEFAULT 0,
"IsCallable" integer NOT NULL DEFAULT 0,
"IsOptional" integer NOT NULL DEFAULT 0,
"IsVariadic" integer NOT NULL DEFAULT 0,
"CanBePassedByValue" integer NOT NULL DEFAULT 0,
"IsPassedByReference" integer NOT NULL DEFAULT 0,
"HasDefaultValue" integer NOT NULL DEFAULT 0,
"DefaultValue" text,
"DefaultConstant" text,
PRIMARY KEY("MethodId","Name"),
CONSTRAINT "FK_METHODPARAMETERS_METHODID" FOREIGN KEY ("MethodId") REFERENCES "ClassMethods" ("Id")
);
CREATE UNIQUE INDEX "IDX_METHODPARAMETERS_NAME" ON MethodParameters ("MethodId", "Name");