2013-02-23 19:33:09 +01:00
|
|
|
CREATE TABLE COLLABORATOR (
|
2013-03-18 03:19:29 +01:00
|
|
|
id SERIAL NOT NULL PRIMARY KEY,
|
|
|
|
email VARCHAR(255) NOT NULL UNIQUE,
|
|
|
|
creation_date DATE
|
2013-02-23 19:33:09 +01:00
|
|
|
);
|
|
|
|
|
2023-02-16 07:47:42 +01:00
|
|
|
CREATE TABLE "USER" (
|
2013-03-18 03:19:29 +01:00
|
|
|
authentication_type TEXT NOT NULL,
|
2013-05-19 16:42:06 +02:00
|
|
|
authenticator_uri VARCHAR(255),
|
2014-01-30 02:15:26 +01:00
|
|
|
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
2013-03-18 03:19:29 +01:00
|
|
|
firstname VARCHAR(255) NOT NULL,
|
|
|
|
lastname VARCHAR(255) NOT NULL,
|
|
|
|
password VARCHAR(255) NOT NULL,
|
|
|
|
activation_code BIGINT NOT NULL,
|
|
|
|
activation_date DATE,
|
|
|
|
allow_send_email TEXT NOT NULL DEFAULT 0,
|
|
|
|
locale VARCHAR(5),
|
2022-12-13 03:36:58 +01:00
|
|
|
google_sync BOOLEAN,
|
|
|
|
sync_code VARCHAR(255),
|
|
|
|
google_token VARCHAR(255),
|
2013-03-18 03:19:29 +01:00
|
|
|
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
|
|
|
);
|
2013-02-23 19:33:09 +01:00
|
|
|
|
2023-02-16 07:47:42 +01:00
|
|
|
CREATE TABLE "LABEL" (
|
2014-01-26 03:07:18 +01:00
|
|
|
id INTEGER NOT NULL PRIMARY KEY,
|
|
|
|
title VARCHAR(255),
|
|
|
|
creator_id INTEGER NOT NULL,
|
2014-01-28 04:13:29 +01:00
|
|
|
parent_label_id INTEGER,
|
2023-02-16 07:47:42 +01:00
|
|
|
color VARCHAR(7) NOT NULL,
|
|
|
|
FOREIGN KEY (creator_id) REFERENCES "USER" (colaborator_id)
|
2014-01-26 03:07:18 +01:00
|
|
|
);
|
|
|
|
|
2013-02-23 19:33:09 +01:00
|
|
|
CREATE TABLE MINDMAP (
|
2013-03-18 03:19:29 +01:00
|
|
|
id SERIAL NOT NULL PRIMARY KEY,
|
|
|
|
title VARCHAR(255) NOT NULL,
|
2023-02-16 07:47:42 +01:00
|
|
|
description VARCHAR(255),
|
2013-03-18 03:19:29 +01:00
|
|
|
xml BYTEA NOT NULL,
|
|
|
|
public BOOL NOT NULL DEFAULT FALSE,
|
|
|
|
creation_date TIMESTAMP,
|
|
|
|
edition_date TIMESTAMP,
|
|
|
|
creator_id INTEGER NOT NULL,
|
2014-01-21 05:46:04 +01:00
|
|
|
last_editor_id INTEGER NOT NULL --,
|
2013-02-23 19:33:09 +01:00
|
|
|
--FOREIGN KEY(creator_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
2013-03-18 03:19:29 +01:00
|
|
|
);
|
2013-02-23 19:33:09 +01:00
|
|
|
|
2022-10-28 03:45:18 +02:00
|
|
|
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),
|
2023-02-16 07:47:42 +01:00
|
|
|
FOREIGN KEY (label_id) REFERENCES "LABEL" (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
2022-10-28 03:45:18 +02:00
|
|
|
);
|
2013-02-23 19:33:09 +01:00
|
|
|
|
|
|
|
CREATE TABLE MINDMAP_HISTORY
|
2013-03-18 03:19:29 +01:00
|
|
|
(id SERIAL NOT NULL PRIMARY KEY,
|
|
|
|
xml BYTEA NOT NULL,
|
|
|
|
mindmap_id INTEGER NOT NULL,
|
|
|
|
creation_date TIMESTAMP,
|
|
|
|
editor_id INTEGER NOT NULL,
|
|
|
|
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
|
|
|
);
|
2013-02-23 19:33:09 +01:00
|
|
|
|
|
|
|
|
2013-03-18 03:19:29 +01:00
|
|
|
CREATE TABLE COLLABORATION_PROPERTIES (
|
|
|
|
id SERIAL NOT NULL PRIMARY KEY,
|
|
|
|
starred BOOL NOT NULL DEFAULT FALSE,
|
|
|
|
mindmap_properties VARCHAR(512)
|
2013-02-23 19:33:09 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE COLLABORATION (
|
2013-03-18 03:19:29 +01:00
|
|
|
id SERIAL NOT NULL PRIMARY KEY,
|
|
|
|
colaborator_id INTEGER NOT NULL,
|
|
|
|
properties_id INTEGER NOT NULL,
|
|
|
|
mindmap_id INTEGER NOT NULL,
|
|
|
|
role_id INTEGER NOT NULL,
|
|
|
|
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
|
|
|
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id) ON DELETE CASCADE ON UPDATE NO ACTION,
|
|
|
|
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
|
|
|
);
|
2013-02-23 19:33:09 +01:00
|
|
|
|
|
|
|
CREATE TABLE ACCESS_AUDITORY (
|
2013-03-18 03:19:29 +01:00
|
|
|
id SERIAL NOT NULL PRIMARY KEY,
|
|
|
|
login_date DATE,
|
2014-01-30 02:15:26 +01:00
|
|
|
user_id INTEGER NOT NULL,
|
2023-02-16 07:47:42 +01:00
|
|
|
FOREIGN KEY (user_id) REFERENCES "USER" (colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
2013-03-18 03:19:29 +01:00
|
|
|
);
|
2013-02-23 19:33:09 +01:00
|
|
|
|
|
|
|
|
2023-02-16 07:47:42 +01:00
|
|
|
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO wisemapping;
|
|
|
|
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO wisemapping;
|
|
|
|
|
2013-02-23 19:33:09 +01:00
|
|
|
COMMIT;
|