-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBscript.sql
71 lines (57 loc) · 1.71 KB
/
DBscript.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
-- Table: "user"
DROP TABLE IF EXISTS recommendation;
DROP TABLE IF EXISTS article;
DROP TABLE IF EXISTS "user";
DROP DATABASE IF EXISTS newsdb;
CREATE DATABASE newsdb;
\c newsdb;
CREATE TABLE "user"
(
id serial NOT NULL,
email character varying NOT NULL,
username character varying NOT NULL,
password character varying NOT NULL,
"isActive" boolean NOT NULL DEFAULT true,
"entryDate" timestamp without time zone NOT NULL DEFAULT now(),
CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
-- Table: article
CREATE TABLE article
(
id serial NOT NULL,
url character varying NOT NULL,
"entryDate" timestamp without time zone NOT NULL DEFAULT now(),
"userId" integer,
CONSTRAINT "PK_40808690eb7b915046558c0f81b" PRIMARY KEY (id),
CONSTRAINT "FK_636f17dadfea1ffb4a412296a28" FOREIGN KEY ("userId")
REFERENCES "user" (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
-- Table: recommendation
CREATE TABLE recommendation
(
id serial NOT NULL,
url character varying NOT NULL,
"entryDate" timestamp without time zone NOT NULL DEFAULT now(),
"userId" integer,
"referralId" integer,
CONSTRAINT "PK_17cb51984a6627ef2ce7370e23c" PRIMARY KEY (id),
CONSTRAINT "FK_61298a446857ac96c88d0a09fd0" FOREIGN KEY ("userId")
REFERENCES "user" (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "FK_8b41af6b454b79ed85c9fd67005" FOREIGN KEY ("referralId")
REFERENCES "user" (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
INSERT INTO "user"(
email, username, password, "isActive", "entryDate")
VALUES ('admin@admin.com','admin', 'admin', true, now());