A little store-level constraining never hurt nobody.
This commit is contained in:
parent
9337b98ad3
commit
4776541df4
|
@ -32,7 +32,8 @@ CREATE TABLE note_relationships (
|
|||
kind TEXT NOT NULL,
|
||||
-- If either note disappears, we want all the edges to disappear as well.
|
||||
FOREIGN KEY (note_id) REFERENCES notes (id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (parent_id) REFERENCES notes (id) ON DELETE CASCADE
|
||||
FOREIGN KEY (parent_id) REFERENCES notes (id) ON DELETE CASCADE,
|
||||
CHECK (note_id <> parent_id)
|
||||
);
|
||||
|
||||
-- This table represents the graph of data relating notes to kastens.
|
||||
|
@ -43,6 +44,7 @@ CREATE TABLE note_kasten_relationships (
|
|||
kind TEXT NOT NULL,
|
||||
-- If either note disappears, we want all the edges to disappear as well.
|
||||
FOREIGN KEY (note_id) REFERENCES notes (id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (kasten_id) REFERENCES notes (id) ON DELETE CASCADE
|
||||
FOREIGN KEY (kasten_id) REFERENCES notes (id) ON DELETE CASCADE,
|
||||
CHECK (note_id <> kasten_id)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue