From bf4f5550d0fce68e1a827bfadbf1404a7e7d2f1e Mon Sep 17 00:00:00 2001
From: Cristiano Urban <cristiano.urban@inaf.it>
Date: Sat, 27 Feb 2021 11:47:16 +0100
Subject: [PATCH] Added 'ON DELETE CASCADE' instruction.

Signed-off-by: Cristiano Urban <cristiano.urban@inaf.it>
---
 00-init.sql | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/00-init.sql b/00-init.sql
index 22528be..6f4ae77 100644
--- a/00-init.sql
+++ b/00-init.sql
@@ -90,7 +90,7 @@ CREATE TABLE node (
     -- storage_id            VARCHAR,    
     protocols              TEXT[]        default NULL,
     PRIMARY KEY (node_id),
-    FOREIGN KEY (location_id) REFERENCES location (location_id)
+    FOREIGN KEY (location_id) REFERENCES location (location_id) ON DELETE CASCADE
 );
 
 
@@ -132,7 +132,7 @@ CREATE TABLE deleted_node (
     -- add a deleted_on timestamp to keep track
     deleted_on             TIMESTAMP     default CURRENT_TIMESTAMP,
     PRIMARY KEY (node_id),
-    FOREIGN KEY (location_id) REFERENCES location (location_id)
+    FOREIGN KEY (location_id) REFERENCES location (location_id) ON DELETE CASCADE
 );
 
 
-- 
GitLab