as SQLite now supports them natively (though we still need to turn them on in Hydra).
7Z7HOZQ3JN5OW2WEU4NWE2XTUWAOHMWDQDJIKKO5KK2ZQTDNJGAAC
E2TOU3L66CH5DA4XPATQM5YM63SFXX63V7SDOIGS4ND3GR7HQALAC
RBNQKATLSAKTGW2IRNB5CRV3SEH5F6E4BPVWX4BII7MH5TCIPINQC
N22GPKYTOLZLBGTGDATQDVZ4R5APZEAOIA7L32X4UXBH4XNI7MWAC
T2232OBSNVDGHY46RY5BBB2IET5LV5OLKSSBDYUF7KAEDBUOTC7QC
A6FXZPKEPNITVXU6DRACBT5DKLMF4A22CFTPKSHSMQDZY4TKMF6AC
KN3VYE5P2RJB3KZ355LA5C2T2D5S2IR3QZFE53AJIWUVMETEEYDAC
6QRHXIM3XHCDLSIIBEGETDV67V6LTV55QMHC64ZPBMLTAECM5N3QC
S6OISBQ3HPFHAAQ5ENG7N3MNGOPNEJPIFKSSA5N4G6KJQTQBSSLQC
#ifdef SQLITE
-- Emulate some "on delete/update cascade" foreign key constraints,
-- which SQLite doesn't support yet.
create trigger cascadeBuildDeletion
before delete on Builds
for each row begin
delete from BuildSchedulingInfo where id = old.id;
delete from BuildResultInfo where id = old.id;
delete from BuildInputs where build = old.id;
delete from BuildProducts where build = old.id;
delete from BuildSteps where build = old.id;
end;
create trigger cascadeProjectUpdate
update of name on Projects
for each row begin
update Jobsets set project = new.name where project = old.name;
update JobsetInputs set project = new.name where project = old.name;
update JobsetInputAlts set project = new.name where project = old.name;
update Builds set project = new.name where project = old.name;
update Views set project = new.name where project = old.name;
update ViewJobs set project = new.name where project = old.name;
end;
create trigger cascadeJobsetUpdate
update of name on Jobsets
for each row begin
update JobsetInputs set jobset = new.name where project = old.project and jobset = old.name;
update JobsetInputAlts set jobset = new.name where project = old.project and jobset = old.name;
update Builds set jobset = new.name where project = old.project and jobset = old.name;
end;
create trigger cascadeJobsetInputUpdate
update of name on JobsetInputs
for each row begin
update JobsetInputAlts set input = new.name where project = old.project and jobset = old.jobset and input = old.name;
end;
create trigger cascadeJobsetInputDelete
before delete on JobsetInputs
for each row begin
delete from JobsetInputAlts where project = old.project and jobset = old.jobset and input = old.name;
end;
create trigger cascadeUserDelete
before delete on Users
for each row begin
delete from UserRoles where userName = old.userName;
end;
create trigger cascadeViewDelete
before delete on Views
for each row begin
delete from ViewJobs where project = old.project and view_ = old.name;
end;
create trigger cascadeViewUpdate
update of name on Views
for each row begin
update ViewJobs set view_ = new.name where project = old.project and view_ = old.name;
end;
#endif