aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
authorAlex Vitkov <alexvitkov98@gmail.com>2021-02-13 16:05:31 +0200
committerAlex Vitkov <alexvitkov98@gmail.com>2021-02-13 16:05:31 +0200
commit511e0d45c6baf716557bd8cc4e0f1ba0de67953f (patch)
tree768e8b01d1349bd83bb5a805eb313146c5f1e06e /sql
parentd72db6897c4eb6638fc43240181218f124958578 (diff)
parent0de674fabe319de356ee1254cb771ecdd194263b (diff)
downloadfileup-511e0d45c6baf716557bd8cc4e0f1ba0de67953f.tar.gz
Merge branch 'master' of https://github.com/alexvitkov/india
Diffstat (limited to 'sql')
-rw-r--r--sql/fileshare.sql24
1 files changed, 23 insertions, 1 deletions
diff --git a/sql/fileshare.sql b/sql/fileshare.sql
index 8e69881..b0c28a5 100644
--- a/sql/fileshare.sql
+++ b/sql/fileshare.sql
@@ -2,6 +2,8 @@
drop table if exists node_access;
drop table if exists users;
drop table if exists node_links;
+drop table if exists trash;
+drop trigger if exists delete_on_zero_links;
drop table if exists nodes;
@@ -42,9 +44,29 @@ create table node_links (
node_id int not null,
name varchar(100) not null default 'no name',
note varchar(200) not null default "",
- check (directory_id != node_id),
foreign key (directory_id) references nodes(node_id) on delete cascade,
foreign key (node_id) references nodes(node_id) on delete cascade
);
+create table trash (
+ node_id int not null,
+ foreign key (node_id) references nodes(node_id) on delete cascade
+);
+
+create trigger delete_on_zero_links
+ after delete
+ on node_links
+ for each row
+ insert into trash
+ select nodes.node_id
+ from nodes
+ where nodes.node_id not in (select node_id from node_links) and nodes.node_id=old.node_id;
+
+ /*
+create trigger delete_links
+ after delete
+ on nodes
+ for each row
+ delete from
+ */