-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.sql
41 lines (35 loc) · 1.21 KB
/
schema.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
CREATE TABLE accounts (
id bigint PRIMARY KEY NOT NULL,
name text,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE posts (
id SERIAL PRIMARY KEY NOT NULL,
account_id bigint NOT NULL REFERENCES accounts(id),
title text,
content text,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE blogs (
id SERIAL PRIMARY KEY NOT NULL,
account_id bigint NOT NULL REFERENCES accounts(id),
title text,
description text,
author_profile text,
coverimage VARCHAR(255),
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX uk_blogs_account_id ON blogs(account_id);
CREATE TABLE sessions (
id CHAR(36) PRIMARY KEY,
account_id bigint NOT NULL REFERENCES accounts(id),
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_accessed_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE stylesheets (
id SERIAL PRIMARY KEY NOT NULL,
account_id bigint NOT NULL REFERENCES accounts(id),
content text,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX uk_stylesheets_account_id ON stylesheets(account_id);