-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.sql
39 lines (34 loc) · 1.07 KB
/
database.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
CREATE DATABASE quarkus;
USE quarkus;
CREATE TABLE user (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
last_connection TIMESTAMP,
active ENUM('YES', 'NO') DEFAULT 'YES',
role ENUM('REGULAR', 'ADMIN') NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE device (
id INT NOT NULL AUTO_INCREMENT,
affected_user_id INT,
state ENUM('WORKING', 'MAINTENANCE', 'ORDERED') NOT NULL,
config TEXT,
PRIMARY KEY (id),
FOREIGN KEY (affected_user_id) REFERENCES user(id) ON DELETE SET NULL
);
CREATE TABLE ticket (
id INT NOT NULL AUTO_INCREMENT,
impact ENUM('MINOR', 'MAJOR', 'BLOCKING') NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
state ENUM('OPEN', 'SOLVED', 'CLOSED') NOT NULL,
user_id INT,
device_id INT,
type VARCHAR(100),
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES user(id) ON DELETE CASCADE,
FOREIGN KEY (device_id) REFERENCES device(id) ON DELETE SET NULL
);