···104104 foreign key (repo_at, issue_id) references issues(repo_at, issue_id) on delete cascade105105 );106106 create table if not exists pulls (107107+ -- identifiers107108 id integer primary key autoincrement,108108- owner_did text not null,109109- repo_at text not null,110109 pull_id integer not null,110110+111111+ -- at identifiers112112+ repo_at text not null,113113+ owner_did text not null,114114+ rkey text not null,115115+ pull_at text,116116+117117+ -- content111118 title text not null,112119 body text not null,113113- patch text,114114- pull_at text,115115- rkey text not null,116120 target_branch text not null,117121 state integer not null default 0 check (state in (0, 1, 2)), -- open, merged, closed122122+123123+ -- meta118124 created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),125125+126126+ -- constraints119127 unique(repo_at, pull_id),120128 foreign key (repo_at) references repos(at_uri) on delete cascade121129 );122122- create table if not exists pull_comments (130130+131131+ -- every pull must have atleast 1 submission: the initial submission132132+ create table if not exists pull_submissions (133133+ -- identifiers123134 id integer primary key autoincrement,124124- owner_did text not null,125135 pull_id integer not null,136136+137137+ -- at identifiers126138 repo_at text not null,127127- comment_id integer not null,128128- comment_at text not null,129129- body text not null,139139+140140+ -- content, these are immutable, and require a resubmission to update141141+ round_number integer not null default 0,142142+ patch text,143143+144144+ -- meta130145 created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),131131- unique(pull_id, comment_id),146146+147147+ -- constraints148148+ unique(repo_at, pull_id, round_number),132149 foreign key (repo_at, pull_id) references pulls(repo_at, pull_id) on delete cascade133150 );151151+152152+ create table if not exists pull_comments (153153+ -- identifiers154154+ id integer primary key autoincrement,155155+ pull_id integer not null,156156+ submission_id integer not null,157157+158158+ -- at identifiers159159+ repo_at text not null,160160+ owner_did text not null,161161+ comment_at text not null,162162+163163+ -- content164164+ body text not null,165165+166166+ -- meta167167+ created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),168168+169169+ -- constraints170170+ foreign key (repo_at, pull_id) references pulls(repo_at, pull_id) on delete cascade,171171+ foreign key (submission_id) references pull_submissions(id) on delete cascade172172+ );173173+134174 create table if not exists _jetstream (135175 id integer primary key autoincrement,136176 last_time_us integer not null