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`);