-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
106 lines (91 loc) · 3.39 KB
/
schema.sql
File metadata and controls
106 lines (91 loc) · 3.39 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
-- Table: public."Roles"
-- DROP TABLE public."Roles";
CREATE TABLE public."Roles"
(
id integer NOT NULL DEFAULT nextval('"Roles_id_seq"'::regclass),
title character varying(255) COLLATE pg_catalog."default" NOT NULL,
"createdAt" timestamp with time zone NOT NULL,
"updatedAt" timestamp with time zone NOT NULL,
CONSTRAINT "Roles_pkey" PRIMARY KEY (id),
CONSTRAINT "Roles_title_key" UNIQUE (title)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."Roles"
OWNER to postgres;
-- Table: public."Users"
-- DROP TABLE public."Users";
CREATE TABLE public."Users"
(
id integer NOT NULL DEFAULT nextval('"Users_id_seq"'::regclass),
name character varying(255) COLLATE pg_catalog."default" NOT NULL,
username character varying(255) COLLATE pg_catalog."default" NOT NULL,
email character varying(255) COLLATE pg_catalog."default" NOT NULL,
password character varying(255) COLLATE pg_catalog."default" NOT NULL,
"createdAt" timestamp with time zone NOT NULL,
"updatedAt" timestamp with time zone NOT NULL,
"roleId" integer,
CONSTRAINT "Users_pkey" PRIMARY KEY (id),
CONSTRAINT "Users_email_key" UNIQUE (email),
CONSTRAINT "Users_username_key" UNIQUE (username),
CONSTRAINT "Users_roleId_fkey" FOREIGN KEY ("roleId")
REFERENCES public."Roles" (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE SET NULL
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."Users"
OWNER to postgres;
-- Table: public."Documents"
-- DROP TABLE public."Documents";
CREATE TABLE public."Documents"
(
id integer NOT NULL DEFAULT nextval('"Documents_id_seq"'::regclass),
title character varying(255) COLLATE pg_catalog."default" NOT NULL,
"docContent" text COLLATE pg_catalog."default",
"docType" character varying(255) COLLATE pg_catalog."default",
"viewAccess" "enum_Documents_viewAccess" DEFAULT 'public'::"enum_Documents_viewAccess",
role character varying(255) COLLATE pg_catalog."default" NOT NULL,
"createdAt" timestamp with time zone NOT NULL,
"updatedAt" timestamp with time zone NOT NULL,
"userId" integer,
CONSTRAINT "Documents_pkey" PRIMARY KEY (id),
CONSTRAINT "Documents_title_key" UNIQUE (title),
CONSTRAINT "Documents_userId_fkey" FOREIGN KEY ("userId")
REFERENCES public."Users" (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE SET NULL
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."Documents"
OWNER to postgres;
-- Table: public."Shareds"
-- DROP TABLE public."Shareds";
CREATE TABLE public."Shareds"
(
id integer NOT NULL DEFAULT nextval('"Shareds_id_seq"'::regclass),
email character varying(255) COLLATE pg_catalog."default" NOT NULL,
"canEdit" boolean DEFAULT false,
"createdAt" timestamp with time zone NOT NULL,
"updatedAt" timestamp with time zone NOT NULL,
"documentId" integer,
CONSTRAINT "Shareds_pkey" PRIMARY KEY (id),
CONSTRAINT "Shareds_documentId_fkey" FOREIGN KEY ("documentId")
REFERENCES public."Documents" (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE SET NULL
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."Shareds"
OWNER to postgres;