Repository navigation
Expand file tree
/
Copy pathdatabase_schema.sql
More file actions
125 lines (99 loc) · 4.02 KB
/
Copy pathdatabase_schema.sql
File metadata and controls
125 lines (99 loc) · 4.02 KB
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
CREATE TABLE case_licenses (
pull_request_id INTEGER PRIMARY KEY,
spdx TEXT NOT NULL
CHECK (
spdx IN (
'MIT',
'BSD-3-Clause',
'Apache-2.0',
'GPL-3.0-only',
'GPL-3.0-or-later'
)
),
resolved_sha TEXT NOT NULL,
FOREIGN KEY (pull_request_id)
REFERENCES pull_requests(id)
);
CREATE TABLE case_provenance (pull_request_id INTEGER PRIMARY KEY REFERENCES pull_requests(id), cohort TEXT NOT NULL, source_pull_request_id INTEGER NOT NULL, source_repository_id INTEGER NOT NULL, source_database TEXT NOT NULL, source_database_sha256 TEXT NOT NULL);
CREATE TABLE pull_request_version_changes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
pull_request_id INTEGER NOT NULL,
version_from TEXT NOT NULL,
version_to TEXT NOT NULL,
UNIQUE(pull_request_id, version_from, version_to),
FOREIGN KEY (pull_request_id)
REFERENCES pull_requests(id)
ON DELETE CASCADE
);
CREATE TABLE pull_requests (
id INTEGER PRIMARY KEY AUTOINCREMENT,
repository_id INTEGER NOT NULL,
pr_number INTEGER NOT NULL,
-- Dependency bots accepted by the study protocol.
bot TEXT NOT NULL
CHECK (bot IN ('dependabot', 'renovate')),
-- Exactly one logical dependency per accepted PR. Its distinct version
-- transitions are normalized in pull_request_version_changes.
dependency TEXT NOT NULL,
created_at TEXT NOT NULL,
-- Descriptive classification of the versioned update. Both kinds remain
-- eligible; this field does not rank or filter one category over the other.
update_kind TEXT NOT NULL
CHECK (
update_kind IN (
'library',
'build_configuration'
)
),
-- base_sha is the immediate state before the automatic PR commits.
-- update_sha is the last consecutive initial commit attributable to the
-- dependency bot, before any later human work in the PR.
base_sha TEXT NOT NULL,
update_sha TEXT NOT NULL,
UNIQUE(repository_id, pr_number),
FOREIGN KEY (repository_id)
REFERENCES repositories(id)
);
CREATE TABLE repositories (
id INTEGER PRIMARY KEY AUTOINCREMENT,
github_id INTEGER NOT NULL UNIQUE,
owner TEXT NOT NULL,
name TEXT NOT NULL,
stars INTEGER NOT NULL,
default_branch_commits INTEGER NOT NULL,
non_bot_contributors INTEGER NOT NULL,
last_non_bot_commit_committer_date TEXT NOT NULL,
archived INTEGER NOT NULL,
declared_targets TEXT NOT NULL,
inspected_sha TEXT NOT NULL DEFAULT '',
tree_truncated INTEGER NOT NULL DEFAULT 0,
has_app_pair INTEGER NOT NULL DEFAULT 0,
android_app_module TEXT,
ios_app_project TEXT,
kmp_module TEXT,
app_pair_reason TEXT NOT NULL DEFAULT 'not_inspected'
);
CREATE TABLE target_results (
id INTEGER PRIMARY KEY AUTOINCREMENT,
test_run_id INTEGER NOT NULL,
-- Planned study targets: android | ios
target TEXT NOT NULL
CHECK (target IN ('android', 'ios')),
-- Planned study outcomes: green | red
status TEXT NOT NULL
CHECK (status IN ('green', 'red')),
UNIQUE(test_run_id, target),
FOREIGN KEY (test_run_id)
REFERENCES test_runs(id)
);
CREATE TABLE test_runs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
pull_request_id INTEGER NOT NULL,
-- Planned study labels: base | update
revision TEXT NOT NULL
CHECK (revision IN ('base', 'update')),
UNIQUE(pull_request_id, revision),
FOREIGN KEY (pull_request_id)
REFERENCES pull_requests(id)
);
CREATE VIEW cases AS SELECT p.id AS case_id, r.owner || '/' || r.name || '#' || p.pr_number AS case_key, r.owner || '/' || r.name AS repository, p.pr_number, cp.cohort, p.dependency, p.update_kind, p.base_sha, p.update_sha, l.spdx AS license_spdx, l.resolved_sha AS license_resolved_sha FROM pull_requests p JOIN repositories r ON r.id=p.repository_id JOIN case_provenance cp ON cp.pull_request_id=p.id LEFT JOIN case_licenses l ON l.pull_request_id=p.id;