From c6975015719a795471e2665555382a8e2994049b Mon Sep 17 00:00:00 2001
From: Eike Kettner <eike.kettner@posteo.de>
Date: Tue, 14 Jul 2020 23:22:52 +0200
Subject: [PATCH] Add folders sql changeset for mariadb

---
 .../db/migration/mariadb/V1.8.0__folders.sql  | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 modules/store/src/main/resources/db/migration/mariadb/V1.8.0__folders.sql

diff --git a/modules/store/src/main/resources/db/migration/mariadb/V1.8.0__folders.sql b/modules/store/src/main/resources/db/migration/mariadb/V1.8.0__folders.sql
new file mode 100644
index 00000000..f94af805
--- /dev/null
+++ b/modules/store/src/main/resources/db/migration/mariadb/V1.8.0__folders.sql
@@ -0,0 +1,34 @@
+CREATE TABLE `folder` (
+  `id` varchar(254) not null primary key,
+  `name` varchar(254) not null,
+  `cid` varchar(254) not null,
+  `owner` varchar(254) not null,
+  `created` timestamp not null,
+  unique (`name`, `cid`),
+  foreign key (`cid`) references `collective`(`cid`),
+  foreign key (`owner`) references `user_`(`uid`)
+);
+
+CREATE TABLE `folder_member` (
+  `id` varchar(254) not null primary key,
+  `folder_id` varchar(254) not null,
+  `user_id` varchar(254) not null,
+  `created` timestamp not null,
+  unique (`folder_id`, `user_id`),
+  foreign key (`folder_id`) references `folder`(`id`),
+  foreign key (`user_id`) references `user_`(`uid`)
+);
+
+ALTER TABLE `item`
+ADD COLUMN `folder_id` varchar(254) NULL;
+
+ALTER TABLE `item`
+ADD FOREIGN KEY (`folder_id`)
+REFERENCES `folder`(`id`);
+
+ALTER TABLE `source`
+ADD COLUMN `folder_id` varchar(254) NULL;
+
+ALTER TABLE `source`
+ADD FOREIGN KEY (`folder_id`)
+REFERENCES `folder`(`id`);