···104 foreign key (repo_at, issue_id) references issues(repo_at, issue_id) on delete cascade
105 );
106 create table if not exists pulls (
0107 id integer primary key autoincrement,
0000108 owner_did text not null,
109- repo_at text not null,
110- pull_id integer not null,
00111 title text not null,
112 body text not null,
113- patch text,
114- pull_at text,
115- rkey text not null,
116 target_branch text not null,
117 state integer not null default 0 check (state in (0, 1, 2)), -- open, merged, closed
00118 created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
00119 unique(repo_at, pull_id),
120 foreign key (repo_at) references repos(at_uri) on delete cascade
121 );
0000000000000000000000122 create table if not exists pull_comments (
0123 id integer primary key autoincrement,
124- owner_did text not null,
125 pull_id integer not null,
000126 repo_at text not null,
127- comment_id integer not null,
128 comment_at text not null,
00129 body text not null,
00130 created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
131- unique(pull_id, comment_id),
132- foreign key (repo_at, pull_id) references pulls(repo_at, pull_id) on delete cascade
00133 );
0134 create table if not exists _jetstream (
135 id integer primary key autoincrement,
136 last_time_us integer not null
···104 foreign key (repo_at, issue_id) references issues(repo_at, issue_id) on delete cascade
105 );
106 create table if not exists pulls (
107+ -- identifiers
108 id integer primary key autoincrement,
109+ pull_id integer not null,
110+111+ -- at identifiers
112+ repo_at text not null,
113 owner_did text not null,
114+ rkey text not null,
115+ pull_at text,
116+117+ -- content
118 title text not null,
119 body text not null,
000120 target_branch text not null,
121 state integer not null default 0 check (state in (0, 1, 2)), -- open, merged, closed
122+123+ -- meta
124 created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
125+126+ -- constraints
127 unique(repo_at, pull_id),
128 foreign key (repo_at) references repos(at_uri) on delete cascade
129 );
130+131+ -- every pull must have atleast 1 submission: the initial submission
132+ create table if not exists pull_submissions (
133+ -- identifiers
134+ id integer primary key autoincrement,
135+ pull_id integer not null,
136+137+ -- at identifiers
138+ repo_at text not null,
139+140+ -- content, these are immutable, and require a resubmission to update
141+ round_number integer not null default 0,
142+ patch text,
143+144+ -- meta
145+ created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
146+147+ -- constraints
148+ unique(repo_at, pull_id, round_number),
149+ foreign key (repo_at, pull_id) references pulls(repo_at, pull_id) on delete cascade
150+ );
151+152 create table if not exists pull_comments (
153+ -- identifiers
154 id integer primary key autoincrement,
0155 pull_id integer not null,
156+ submission_id integer not null,
157+158+ -- at identifiers
159 repo_at text not null,
160+ owner_did text not null,
161 comment_at text not null,
162+163+ -- content
164 body text not null,
165+166+ -- meta
167 created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
168+169+ -- constraints
170+ foreign key (repo_at, pull_id) references pulls(repo_at, pull_id) on delete cascade,
171+ foreign key (submission_id) references pull_submissions(id) on delete cascade
172 );
173+174 create table if not exists _jetstream (
175 id integer primary key autoincrement,
176 last_time_us integer not null