-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_tables.sql
80 lines (73 loc) · 2.16 KB
/
create_tables.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
-- Tables for User Details
CREATE TABLE user_details (
user_id serial PRIMARY KEY,
username VARCHAR ( 255 ) UNIQUE NOT NULL,
name VARCHAR(255) ,
gitToken VARCHAR ( 255 ) NOT NULL,
key VARCHAR(255) UNIQUE,
email VARCHAR ( 255 ) UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT now(),
recent_login_at TIMESTAMP NOT NULL
);
-- Table for Deployment Details
CREATE TABLE deployment_details (
id serial PRIMARY KEY,
name VARCHAR ( 255 ) UNIQUE NOT NULL,
recent_update_at TIMESTAMP NOT NULL
);
-- Table for Kit Details
CREATE TABLE kit_details(
id serial PRIMARY KEY,
name VARCHAR( 255 ) NOT NULL,
version VARCHAR( 255 ) NOT NULL,
deployment_id int NOT NULL,
deployed_by VARCHAR( 255 ),
deployed_at VARCHAR( 255 ) NOT NULL,
features VARCHAR( 255 ),
is_dev INT,
sync_with_github BOOLEAN,
recent_update_at TIMESTAMP NOT NULL,
UNIQUE (name, deployment_id),
CONSTRAINT fk_kit_deployment
FOREIGN KEY ( deployment_id )
REFERENCES deployment_details ( id )
);
-- Table for Quickviews
CREATE TABLE quickviews(
id serial PRIMARY KEY,
user_name VARCHAR ( 255 ) NOT NULL,
name VARCHAR( 255 ) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now(),
UNIQUE(name,user_name),
CONSTRAINT fk_quickviews
FOREIGN KEY ( user_name )
REFERENCES user_details ( username )
);
-- Table for Quickviews Values
CREATE TABLE quickviews_values(
id serial PRIMARY KEY,
quickview_id INT NOT NULL,
qv_value VARCHAR( 255 ) NOT NULL,
qv_value_type VARCHAR( 255 ) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now(),
CONSTRAINT fk_quickview_values
FOREIGN KEY ( quickview_id )
REFERENCES quickviews ( id )
);
------Table for Deployment deatils from the GitHub Repo -------
CREATE TABLE deployment_details_github(
id serial PRIMARY KEY,
deployment_name VARCHAR ( 255 ) NOT NULL,
kit_name VARCHAR(255) NOT NULL,
deployment_id int NOT NULL,
version VARCHAR( 255 ) NOT NULL,
deployed_by VARCHAR( 255 ),
deployed_at VARCHAR( 255 ) NOT NULL,
features VARCHAR( 255 ),
is_dev INT,
recent_update_at TIMESTAMP NOT NULL,
UNIQUE (kit_name, deployment_id),
CONSTRAINT fk_kit_deployment
FOREIGN KEY ( deployment_id )
REFERENCES deployment_details ( id )
)