2015-02-17 16:17:38 +01:00
|
|
|
#Ce fichier contient la base de données à créer
|
|
|
|
|
|
|
|
CREATE DATABASE IF NOT EXISTS raspisms;
|
|
|
|
USE raspisms;
|
|
|
|
|
2015-09-21 22:44:51 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS settings
|
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
name VARCHAR(20) NOT NULL,
|
|
|
|
value VARCHAR(1000) NOT NULL,
|
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS receiveds
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
at DATETIME NOT NULL,
|
|
|
|
send_by VARCHAR(12) NOT NULL,
|
|
|
|
content VARCHAR(1000) NOT NULL,
|
|
|
|
is_command BOOLEAN NOT NULL,
|
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS sendeds
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
at DATETIME NOT NULL,
|
|
|
|
target VARCHAR(12) NOT NULL,
|
|
|
|
content VARCHAR(1000) NOT NULL,
|
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS scheduleds
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
at DATETIME NOT NULL,
|
|
|
|
content VARCHAR(1000) NOT NULL,
|
2015-08-09 22:50:10 +02:00
|
|
|
progress BOOLEAN NOT NULL DEFAULT 0,
|
2015-02-17 16:17:38 +01:00
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS contacts
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
name VARCHAR(100) NOT NULL,
|
|
|
|
number VARCHAR(12) NOT NULL,
|
2015-08-16 00:06:31 +02:00
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (name)
|
2015-02-17 16:17:38 +01:00
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS groups
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
name VARCHAR(100) NOT NULL,
|
2015-08-16 00:06:31 +02:00
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (name)
|
2015-02-17 16:17:38 +01:00
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS groups_contacts
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
id_group INT NOT NULL,
|
|
|
|
id_contact INT NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
FOREIGN KEY (id_group) REFERENCES groups (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
|
|
FOREIGN KEY (id_contact) REFERENCES contacts (id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS scheduleds_contacts
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
id_scheduled INT NOT NULL,
|
|
|
|
id_contact INT NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
FOREIGN KEY (id_scheduled) REFERENCES scheduleds (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
|
|
FOREIGN KEY (id_contact) REFERENCES contacts (id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS scheduleds_groups
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
id_scheduled INT NOT NULL,
|
|
|
|
id_group INT NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
FOREIGN KEY (id_scheduled) REFERENCES scheduleds (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
|
|
FOREIGN KEY (id_group) REFERENCES groups (id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS scheduleds_numbers
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
id_scheduled INT NOT NULL,
|
|
|
|
number VARCHAR(12) NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
FOREIGN KEY (id_scheduled) REFERENCES scheduleds (id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS commands
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
name VARCHAR(25) NOT NULL,
|
|
|
|
script VARCHAR(100) NOT NULL,
|
|
|
|
admin BOOLEAN NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (name)
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS events
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
type VARCHAR(25) NOT NULL,
|
2015-08-09 18:11:59 +02:00
|
|
|
at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2015-02-17 16:17:38 +01:00
|
|
|
text VARCHAR(255) NOT NULL,
|
|
|
|
PRIMARY KEY (id)
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS users
|
2015-02-17 16:17:38 +01:00
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
email VARCHAR(255) NOT NULL,
|
|
|
|
password VARCHAR(255) NOT NULL,
|
2015-08-18 04:37:20 +02:00
|
|
|
admin BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
transfer BOOLEAN NOT NULL DEFAULT FALSE,
|
2015-02-17 16:17:38 +01:00
|
|
|
PRIMARY KEY (id),
|
|
|
|
UNIQUE (email)
|
|
|
|
);
|
|
|
|
|
2015-08-18 04:37:20 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS transfers
|
|
|
|
(
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
id_received INT NOT NULL,
|
|
|
|
progress BOOLEAN NOT NULL DEFAULT 0,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
FOREIGN KEY (id_received) REFERENCES receiveds (id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
);
|
2015-09-21 22:44:51 +02:00
|
|
|
|
|
|
|
#On insert les données par défaut dans les settings
|
|
|
|
INSERT INTO settings (name, value)
|
|
|
|
VALUES ('transfer', '1');
|