-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb-schema.sql
88 lines (73 loc) · 1.81 KB
/
db-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
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
CREATE EXTENSION ltree;
DROP TABLE IF EXISTS Posts;
CREATE TABLE Posts (
"id" SERIAL,
"postKey" ltree NOT NULL,
"title" varchar(150) NOT NULL,
"text" text NOT NULL,
"url" varchar(250) NOT NULL,
"investors" text[],
"investment" int NOT NULL,
"username" varchar(24) NOT NULL,
"commentCount" int NOT NULL,
"html" text,
"thumbnail" varchar(255),
"timestamp" bigint NOT NULL,
"sticky" boolean NOT NULL,
PRIMARY KEY ("id")
);
DROP TABLE IF EXISTS Votes;
CREATE TABLE Votes (
"id" SERIAL,
"userId" int NOT NULL,
"postId" int NOT NULL,
"timestamp" bigint NOT NULL,
PRIMARY KEY ("id")
);
DROP TABLE IF EXISTS Forums;
CREATE TABLE Forums (
"id" SERIAL,
"name" varchar(150) NOT NULL,
"description" varchar(1000) NOT NULL,
"rules" varchar(1000) NOT NULL,
"administrator" varchar(24) NOT NULL,
"timestamp" bigint NOT NULL,
PRIMARY KEY ("id")
);
CREATE TYPE rank AS ENUM ('newbie', 'hero');
CREATE TYPE status AS ENUM ('user', 'mod', 'admin');
DROP TABLE IF EXISTS Users;
CREATE TABLE Users (
"id" SERIAL,
"username" varchar(24) NOT NULL,
"email" varchar(64) NOT NULL,
"passwordHash" varchar(44) NOT NULL,
"salt" varchar(24) NOT NULL,
"key" varchar(64) NOT NULL,
"address" varchar(35) NOT NULL,
"balance" int NOT NULL,
"joined" bigint NOT NULL,
"rank" rank,
"status" status,
"secret" varchar(24) NOT NULL,
PRIMARY KEY ("id")
);
DROP TABLE IF EXISTS Payments;
CREATE TABLE Payments (
"id" SERIAL,
"amount" int NOT NULL,
"transactionHash" varchar(64) NOT NULL,
"username" varchar(24),
"kind" varchar(24),
"timestamp" bigint NOT NULL,
PRIMARY KEY ("id")
);
DROP TABLE IF EXISTS Wallet;
CREATE TABLE Wallet (
"id" SERIAL,
"key" varchar(64) NOT NULL,
"address" varchar(35) NOT NULL,
"balance" int NOT NULL,
"username" varchar(24),
PRIMARY KEY ("id")
);