-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1init.sql
More file actions
49 lines (44 loc) · 1.23 KB
/
Copy path1init.sql
File metadata and controls
49 lines (44 loc) · 1.23 KB
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
40
41
42
43
44
45
46
47
48
49
CREATE TYPE ticketProgressStatus AS ENUM (
'open', 'in progress', 'review', 'test', 'closed'
);
CREATE TYPE userRole AS ENUM (
'admin', 'write', 'read'
);
CREATE TABLE Users (
id serial PRIMARY KEY,
name varchar(100) not null,
email varchar(150) not null,
password varchar not null,
UNIQUE (email),
CONSTRAINT valid_user CHECK (
name <> '' and email <> '' and password <> ''
)
);
CREATE TABLE Dashboards (
id serial PRIMARY KEY,
name varchar(100) not null,
description character varying,
date_of_creation timestamp not null,
creator_id integer REFERENCES Users not null
);
CREATE TABLE Tickets (
id serial PRIMARY KEY,
title varchar(300) not null,
description character varying,
date_of_creation timestamp not null,
creator_id integer REFERENCES Users not null,
dashboard_id integer REFERENCES Dashboards not null,
assignee integer REFERENCES Users,
status ticketProgressStatus default 'open',
CONSTRAINT valid_ticket CHECK (
title <> ''
),
UNIQUE (dashboard_id, creator_id)
);
CREATE TABLE DashboardToUser (
id serial PRIMARY KEY,
dashboard_id integer REFERENCES Dashboards not null,
user_id integer REFERENCES Users not null,
role userRole not null,
UNIQUE (dashboard_id, user_id)
);