-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
31 lines (28 loc) · 882 Bytes
/
init.sql
File metadata and controls
31 lines (28 loc) · 882 Bytes
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
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
password_digest TEXT,
bio TEXT,
picture_path TEXT
);
CREATE TABLE IF NOT EXISTS courses (
id SERIAL PRIMARY KEY,
author_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
title VARCHAR(255) NOT NULL,
descr TEXT,
thumbnail_path TEXT,
file_path TEXT
);
CREATE TABLE IF NOT EXISTS user_sub_courses (
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
course_id INTEGER REFERENCES courses(id) ON DELETE CASCADE,
subscription_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (user_id, course_id)
);
CREATE TABLE IF NOT EXISTS "session" (
"sid" VARCHAR NOT NULL COLLATE "default",
"sess" JSON NOT NULL,
"expire" TIMESTAMP(6) NOT NULL,
PRIMARY KEY ("sid")
) WITH (OIDS=FALSE);