···331 unique(instance)
332 );
3330000000000000000000000000000000000000000000000000000000000000334 create table if not exists migrations (
335 id integer primary key autoincrement,
336 name text unique
337- )
338 `)
339 if err != nil {
340 return nil, err
···331 unique(instance)
332 );
333334+ create table if not exists pipelines (
335+ -- identifiers
336+ id integer primary key autoincrement,
337+ knot text not null,
338+ rkey text not null,
339+340+ repo_owner text not null,
341+ repo_name text not null,
342+343+ -- every pipeline must be associated with exactly one commit
344+ sha text not null check (length(sha) = 40),
345+346+ -- trigger data
347+ trigger_id integer not null,
348+349+ unique(knot, rkey),
350+ foreign key (trigger_id) references triggers(id) on delete cascade
351+ );
352+353+ create table if not exists triggers (
354+ -- primary key
355+ id integer primary key autoincrement,
356+357+ -- top-level fields
358+ kind text not null,
359+360+ -- pushTriggerData fields
361+ push_ref text,
362+ push_new_sha text check (length(push_new_sha) = 40),
363+ push_old_sha text check (length(push_old_sha) = 40),
364+365+ -- pullRequestTriggerData fields
366+ pr_source_branch text,
367+ pr_target_branch text,
368+ pr_source_sha text check (length(pr_source_sha) = 40),
369+ pr_action text
370+ );
371+372+ create table if not exists pipeline_statuses (
373+ -- identifiers
374+ id integer primary key autoincrement,
375+ spindle text not null,
376+ rkey text not null,
377+378+ -- referenced pipeline. these form the (did, rkey) pair
379+ pipeline_knot text not null,
380+ pipeline_rkey text not null,
381+382+ -- content
383+ created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
384+ workflow text not null,
385+ status text not null,
386+ error text,
387+ exit_code integer not null default 0,
388+389+ unique (spindle, rkey),
390+ foreign key (pipeline_knot, pipeline_rkey)
391+ references pipelines (knot, rkey)
392+ on delete cascade
393+ );
394+395 create table if not exists migrations (
396 id integer primary key autoincrement,
397 name text unique
398+ );
399 `)
400 if err != nil {
401 return nil, err