diff --git a/server/nm-store/src/sql/initialize_database.sql b/server/nm-store/src/sql/initialize_database.sql index e72adba..3ad220d 100644 --- a/server/nm-store/src/sql/initialize_database.sql +++ b/server/nm-store/src/sql/initialize_database.sql @@ -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) );