1 DROP TABLE run_iterations CASCADE;
2 DROP TABLE test_runs CASCADE;
3 DROP TABLE test_configurations CASCADE;
4 DROP TYPE test_configuration_type CASCADE;
5 DROP TABLE aggregators CASCADE;
6 DROP TABLE builds CASCADE;
7 DROP TABLE committers CASCADE;
8 DROP TABLE commits CASCADE;
9 DROP TABLE build_commits CASCADE;
10 DROP TABLE build_slaves CASCADE;
11 DROP TABLE builders CASCADE;
12 DROP TABLE repositories CASCADE;
13 DROP TABLE platforms CASCADE;
14 DROP TABLE test_metrics CASCADE;
15 DROP TABLE tests CASCADE;
16 DROP TABLE reports CASCADE;
17 DROP TABLE tracker_repositories CASCADE;
18 DROP TABLE bug_trackers CASCADE;
19 DROP TABLE analysis_tasks CASCADE;
20 DROP TABLE bugs CASCADE;
21 DROP TABLE analysis_test_groups CASCADE;
22 DROP TABLE root_sets CASCADE;
23 DROP TABLE build_requests CASCADE;
26 CREATE TABLE platforms (
27 platform_id serial PRIMARY KEY,
28 platform_name varchar(64) NOT NULL,
29 platform_hidden boolean NOT NULL DEFAULT FALSE);
31 CREATE TABLE repositories (
32 repository_id serial PRIMARY KEY,
33 repository_name varchar(64) NOT NULL,
34 repository_url varchar(1024),
35 repository_blame_url varchar(1024));
37 CREATE TABLE bug_trackers (
38 tracker_id serial PRIMARY KEY,
39 tracker_name varchar(64) NOT NULL,
40 tracker_bug_url varchar(1024),
41 tracker_new_bug_url varchar(1024));
43 CREATE TABLE tracker_repositories (
44 tracrepo_tracker integer NOT NULL REFERENCES bug_trackers ON DELETE CASCADE,
45 tracrepo_repository integer NOT NULL REFERENCES repositories ON DELETE CASCADE);
47 CREATE TABLE builders (
48 builder_id serial PRIMARY KEY,
49 builder_name varchar(64) NOT NULL UNIQUE,
50 builder_password_hash character(64),
51 builder_build_url varchar(1024));
53 CREATE TABLE build_slaves (
54 slave_id serial PRIMARY KEY,
55 slave_name varchar(64) NOT NULL UNIQUE,
56 slave_password_hash character(64));
59 build_id serial PRIMARY KEY,
60 build_builder integer REFERENCES builders ON DELETE CASCADE,
61 build_slave integer REFERENCES build_slaves ON DELETE CASCADE,
62 build_number integer NOT NULL,
63 build_time timestamp NOT NULL,
64 build_latest_revision timestamp,
65 CONSTRAINT builder_build_time_tuple_must_be_unique UNIQUE(build_builder, build_number, build_time));
66 CREATE INDEX build_builder_index ON builds(build_builder);
68 CREATE TABLE committers (
69 committer_id serial PRIMARY KEY,
70 committer_repository integer NOT NULL REFERENCES repositories ON DELETE CASCADE,
71 committer_account varchar(320) NOT NULL,
72 committer_name varchar(128),
73 CONSTRAINT committer_in_repository_must_be_unique UNIQUE(committer_repository, committer_account));
74 CREATE INDEX committer_account_index ON committers(committer_account);
75 CREATE INDEX committer_name_index ON committers(committer_name);
77 CREATE TABLE commits (
78 commit_id serial PRIMARY KEY,
79 commit_repository integer NOT NULL REFERENCES repositories ON DELETE CASCADE,
80 commit_revision varchar(64) NOT NULL,
81 commit_parent integer REFERENCES commits ON DELETE CASCADE,
82 commit_time timestamp,
83 commit_committer integer REFERENCES committers ON DELETE CASCADE,
85 commit_reported boolean NOT NULL DEFAULT FALSE,
86 CONSTRAINT commit_in_repository_must_be_unique UNIQUE(commit_repository, commit_revision));
87 CREATE INDEX commit_time_index ON commits(commit_time);
89 CREATE TABLE build_commits (
90 commit_build integer NOT NULL REFERENCES builds ON DELETE CASCADE,
91 build_commit integer NOT NULL REFERENCES commits ON DELETE CASCADE,
92 PRIMARY KEY (commit_build, build_commit));
94 CREATE TABLE aggregators (
95 aggregator_id serial PRIMARY KEY,
96 aggregator_name varchar(64),
97 aggregator_definition text);
100 test_id serial PRIMARY KEY,
101 test_name varchar(255) NOT NULL,
102 test_parent integer REFERENCES tests ON DELETE CASCADE,
103 test_url varchar(1024) DEFAULT NULL,
104 CONSTRAINT parent_test_must_be_unique UNIQUE(test_parent, test_name));
106 CREATE TABLE test_metrics (
107 metric_id serial PRIMARY KEY,
108 metric_test integer NOT NULL REFERENCES tests ON DELETE CASCADE,
109 metric_name varchar(64) NOT NULL,
110 metric_aggregator integer REFERENCES aggregators ON DELETE CASCADE);
112 CREATE TYPE test_configuration_type as ENUM ('current', 'baseline', 'target');
113 CREATE TABLE test_configurations (
114 config_id serial PRIMARY KEY,
115 config_metric integer NOT NULL REFERENCES test_metrics ON DELETE CASCADE,
116 config_platform integer NOT NULL REFERENCES platforms ON DELETE CASCADE,
117 config_type test_configuration_type NOT NULL,
118 config_is_in_dashboard boolean NOT NULL DEFAULT FALSE,
119 CONSTRAINT configuration_must_be_unique UNIQUE(config_metric, config_platform, config_type));
120 CREATE INDEX config_platform_index ON test_configurations(config_platform);
122 CREATE TABLE test_runs (
123 run_id serial PRIMARY KEY,
124 run_config integer NOT NULL REFERENCES test_configurations ON DELETE CASCADE,
125 run_build integer NOT NULL REFERENCES builds ON DELETE CASCADE,
126 run_iteration_count_cache smallint,
127 run_mean_cache double precision,
128 run_sum_cache double precision,
129 run_square_sum_cache double precision,
130 CONSTRAINT test_config_build_must_be_unique UNIQUE(run_config, run_build));
131 CREATE INDEX run_config_index ON test_runs(run_config);
132 CREATE INDEX run_build_index ON test_runs(run_build);
134 CREATE TABLE run_iterations (
135 iteration_run integer NOT NULL REFERENCES test_runs ON DELETE CASCADE,
136 iteration_order smallint NOT NULL CHECK(iteration_order >= 0),
137 iteration_group smallint CHECK(iteration_group >= 0),
138 iteration_value double precision,
139 iteration_relative_time float,
140 PRIMARY KEY (iteration_run, iteration_order));
142 CREATE TABLE reports (
143 report_id serial PRIMARY KEY,
144 report_builder integer NOT NULL REFERENCES builders ON DELETE RESTRICT,
145 report_slave integer REFERENCES build_slaves ON DELETE RESTRICT,
146 report_build_number integer,
147 report_build integer REFERENCES builds,
148 report_created_at timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'),
149 report_committed_at timestamp,
151 report_failure varchar(64),
152 report_failure_details text);
154 CREATE TABLE analysis_tasks (
155 task_id serial PRIMARY KEY,
156 task_name varchar(256) NOT NULL,
157 task_author varchar(256),
158 task_created_at timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'),
159 task_platform integer REFERENCES platforms NOT NULL,
160 task_metric integer REFERENCES test_metrics NOT NULL,
161 task_start_run integer REFERENCES test_runs,
162 task_end_run integer REFERENCES test_runs,
163 CONSTRAINT analysis_task_should_be_unique_for_range UNIQUE(task_start_run, task_end_run),
164 CONSTRAINT analysis_task_should_not_be_associated_with_single_run
165 CHECK ((task_start_run IS NULL AND task_end_run IS NULL) OR (task_start_run IS NOT NULL AND task_end_run IS NOT NULL)));
168 bug_id serial PRIMARY KEY,
169 bug_task integer REFERENCES analysis_tasks NOT NULL,
170 bug_tracker integer REFERENCES bug_trackers NOT NULL,
171 bug_number integer NOT NULL,
172 CONSTRAINT bug_task_and_tracker_must_be_unique UNIQUE(bug_task, bug_tracker));
174 CREATE TABLE analysis_test_groups (
175 testgroup_id serial PRIMARY KEY,
176 testgroup_task integer REFERENCES analysis_tasks NOT NULL,
177 testgroup_name varchar(256),
178 testgroup_author varchar(256) NOT NULL,
179 testgroup_created_at timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'));
180 CREATE INDEX testgroup_task_index ON analysis_test_groups(testgroup_task);
182 CREATE TABLE root_sets (
183 rootset_id serial PRIMARY KEY);
185 CREATE TABLE build_requests (
186 request_id serial PRIMARY KEY,
187 request_group integer REFERENCES analysis_test_groups NOT NULL,
188 request_order integer NOT NULL,
189 request_root_set integer REFERENCES root_sets NOT NULL,
190 request_build integer REFERENCES builds,
191 CONSTRAINT build_request_order_must_be_unique_in_group UNIQUE(request_group, request_order));