From 504e3e18e62574ac0f2188d9d3dc5e2df68167c0 Mon Sep 17 00:00:00 2001 From: Ezequiel Bergamaschi Date: Sat, 25 Jan 2014 23:07:18 -0300 Subject: [PATCH] sql scripts for label support --- config/database/hsql/create-schemas.sql | 16 ++++++++++++++ config/database/hsql/drop-schemas.sql | 1 + config/database/mysql/create-schemas.sql | 23 +++++++++++++++++++++ config/database/mysql/drop-schemas.sql | 1 + config/database/postgres/create-schemas.sql | 15 ++++++++++++++ config/database/postgres/drop-schemas.sql | 1 + 6 files changed, 57 insertions(+) diff --git a/config/database/hsql/create-schemas.sql b/config/database/hsql/create-schemas.sql index 69bf4c0e..8c59238b 100644 --- a/config/database/hsql/create-schemas.sql +++ b/config/database/hsql/create-schemas.sql @@ -32,6 +32,22 @@ CREATE TABLE MINDMAP ( --FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id) ); +CREATE TABLE LABEL ( + id INTEGER NOT NULL PRIMARY KEY IDENTITY, + title VARCHAR(255), + creator_id INTEGER NOT NULL, + parent_label_id INTEGER + --FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id) +); + +CREATE TABLE R_LABEL_MINDMAP ( + mindmap_id INTEGER NOT NULL, + label_id INTEGER NOT NULL, + PRIMARY KEY (mindmap_id, label_id), + FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id), + FOREIGN KEY (label_id) REFERENCES LABEL (id) +); + CREATE TABLE MINDMAP_HISTORY (id INTEGER NOT NULL IDENTITY, xml LONGVARBINARY NOT NULL, diff --git a/config/database/hsql/drop-schemas.sql b/config/database/hsql/drop-schemas.sql index a0de242f..8b1b1526 100644 --- a/config/database/hsql/drop-schemas.sql +++ b/config/database/hsql/drop-schemas.sql @@ -3,6 +3,7 @@ DROP TABLE IF EXISTS TAG; DROP TABLE IF EXISTS COLLABORATION; DROP TABLE IF EXISTS COLLABORATION_PROPERTIES; DROP TABLE IF EXISTS MINDMAP_HISTORY; +DROP TABLE IF EXISTS LABEL; DROP TABLE IF EXISTS MINDMAP; DROP TABLE IF EXISTS USER; DROP TABLE IF EXISTS COLLABORATOR; diff --git a/config/database/mysql/create-schemas.sql b/config/database/mysql/create-schemas.sql index 4e26a3fc..35467873 100644 --- a/config/database/mysql/create-schemas.sql +++ b/config/database/mysql/create-schemas.sql @@ -48,6 +48,29 @@ CREATE TABLE MINDMAP ( ) CHARACTER SET utf8; +CREATE TABLE LABEL ( + id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, + title VARCHAR(255) + CHARACTER SET utf8 NOT NULL, + creator_id INTEGER NOT NULL, + parent_label_id INTEGER, + FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id), + FOREIGN KEY (parent_label_id) REFERENCES LABEL (id) + ON DELETE CASCADE + ON UPDATE NO ACTION +) + CHARACTER SET utf8; + +CREATE TABLE R_LABEL_MINDMAP ( + mindmap_id INTEGER NOT NULL, + label_id INTEGER NOT NULL, + PRIMARY KEY (mindmap_id, label_id), + FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id), + FOREIGN KEY (label_id) REFERENCES LABEL (id) + ON DELETE CASCADE + ON UPDATE NO ACTION +) + CHARACTER SET utf8; CREATE TABLE MINDMAP_HISTORY (id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, diff --git a/config/database/mysql/drop-schemas.sql b/config/database/mysql/drop-schemas.sql index 6a5af0e5..0b85387b 100644 --- a/config/database/mysql/drop-schemas.sql +++ b/config/database/mysql/drop-schemas.sql @@ -3,6 +3,7 @@ DROP TABLE IF EXISTS ACCESS_AUDITORY; DROP TABLE IF EXISTS COLLABORATION; DROP TABLE IF EXISTS COLLABORATION_PROPERTIES; DROP TABLE IF EXISTS MINDMAP_HISTORY; +DROP TABLE IF EXISTS LABEL; DROP TABLE IF EXISTS MINDMAP; DROP TABLE IF EXISTS USER; DROP TABLE IF EXISTS COLLABORATOR; diff --git a/config/database/postgres/create-schemas.sql b/config/database/postgres/create-schemas.sql index 723cc2dd..52b30da3 100644 --- a/config/database/postgres/create-schemas.sql +++ b/config/database/postgres/create-schemas.sql @@ -19,6 +19,21 @@ CREATE TABLE "user" ( FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id) ON DELETE CASCADE ON UPDATE NO ACTION ); +CREATE TABLE LABEL ( + id INTEGER NOT NULL PRIMARY KEY, + title VARCHAR(255), + creator_id INTEGER NOT NULL, + parent_label_id INTEGER + --FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id) +); + +CREATE TABLE R_LABEL_MINDMAP ( + mindmap_id INTEGER NOT NULL, + label_id INTEGER NOT NULL, + PRIMARY KEY (mindmap_id, label_id), + FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id), + FOREIGN KEY (label_id) REFERENCES LABEL (id) +); CREATE TABLE MINDMAP ( id SERIAL NOT NULL PRIMARY KEY, diff --git a/config/database/postgres/drop-schemas.sql b/config/database/postgres/drop-schemas.sql index ea2ddf18..e299a31b 100644 --- a/config/database/postgres/drop-schemas.sql +++ b/config/database/postgres/drop-schemas.sql @@ -3,6 +3,7 @@ DROP TABLE ACCESS_AUDITORY; DROP TABLE COLLABORATION; DROP TABLE COLLABORATION_PROPERTIES; DROP TABLE MINDMAP_HISTORY; +DROP TABLE LABEL; DROP TABLE MINDMAP; DROP TABLE "user"; DROP TABLE COLLABORATOR;