aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/schema.sql
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-02-22 14:18:55 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-02-22 14:18:55 +0000
commit9cda61694957f2f0428779319f85f626578d0cf0 (patch)
treed03651a9108d84e90ba9ff43183de3671a6b1ff1 /src/libstore/schema.sql
parentc4d388add4942f6f99a8df12f4e49149005047e2 (diff)
* The database needs a trigger to get rid of self-references to
prevent a foreign key constraint violation on the Refs table when deleting a path.
Diffstat (limited to 'src/libstore/schema.sql')
-rw-r--r--src/libstore/schema.sql10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstore/schema.sql b/src/libstore/schema.sql
index 682ce5ed7..4adad34b7 100644
--- a/src/libstore/schema.sql
+++ b/src/libstore/schema.sql
@@ -17,6 +17,16 @@ create table if not exists Refs (
create index if not exists IndexReferrer on Refs(referrer);
create index if not exists IndexReference on Refs(reference);
+-- Paths can refer to themselves, causing a tuple (N, N) in the Refs
+-- table. This causes a deletion of the corresponding row in
+-- ValidPaths to cause a foreign key constraint violation (due to `on
+-- delete restrict' on the `reference' column). Therefore, explicitly
+-- get rid of self-references.
+create trigger DeleteSelfRefs before delete on ValidPaths
+ begin
+ delete from Refs where referrer = old.id and reference = old.id;
+ end;
+
create table if not exists DerivationOutputs (
drv integer not null,
id text not null, -- symbolic output id, usually "out"