aboutsummaryrefslogtreecommitdiff
path: root/database/db.sql
blob: 0327b12e9274d61dcd20140f49de9c7aebbec4cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- Database structure of penchan.club
-- Every post is stored in the post table
-- there can be multiple boards, they don't need to have their own table, by default posts go to /b/
-- picture is a base64 png data URL
-- thread point to the OP of a thread, if thread is null the post begin a new thread
-- reply_to is if someone wanna reply to someone else
-- ip_address is poster's IP, in case someone spam CP and my server get seized
-- special is mostly to mark messages as being sent by VIPs (like mods or site admin)

BEGIN;

CREATE TABLE "post" (
	"id" int GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
	"board" text DEFAULT 'b',
	"picture" text NOT NULL,
	"thread" int REFERENCES "post"("id"),
	"reply_to" int REFERENCES "post"("id"),
	"ip_address" text,
	"special" text,
	"created_at" timestamptz NOT NULL DEFAULT now(),
	"updated_at" timestamptz
);

COMMIT;