add on delete contraints to schema

This commit is contained in:
xenia 2020-11-16 23:10:13 -05:00
parent 8c66fe69de
commit 2d45fe666b
1 changed files with 4 additions and 4 deletions

View File

@ -10,7 +10,7 @@ create table node(id integer primary key, name text not null, arch text not null
-- @up {
create table node_resource(nodeid integer not null, resource text not null,
unique (nodeid, resource),
foreign key(nodeid) references node(id));
foreign key(nodeid) references node(id) on delete cascade);
-- }
-- @up {
create table task(id integer primary key, name text not null, manifest blob not null,
@ -21,12 +21,12 @@ create table task_log(taskid integer not null, worker integer not null,
time_start timestamp not null,
time_end timestamp check(time_end >= time_start) not null,
pattern blob not null,
foreign key (taskid) references tasks(id),
foreign key (worker) references node(id));
foreign key (taskid) references tasks(id) on delete cascade,
foreign key (worker) references node(id) on delete restrict);
-- }
-- @up {
create table task_match(taskid integer not null, time timestamp not null, match blob not null,
foreign key (taskid) references tasks(id));
foreign key (taskid) references tasks(id) on delete cascade);
-- }
-- @down {