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