CrossTalkPM/src/db/migrations/001_create_comments_table.sql

25 lines
818 B
SQL

CREATE TABLE IF NOT EXISTS comments (
db_id INTEGER PRIMARY KEY,
id INTEGER UNIQUE NOT NULL,
author_id INTEGER NOT NULL,
author_name TEXT NOT NULL,
body TEXT NOT NULL,
body_html TEXT NOT NULL,
created_utc INTEGER NOT NULL,
deleted_utc INTEGER DEFAULT 0,
distinguished BOOLEAN DEFAULT FALSE,
downvotes INTEGER DEFAULT 0,
edited_utc INTEGER DEFAULT 0,
is_banned BOOLEAN DEFAULT FALSE,
is_bot BOOLEAN DEFAULT FALSE,
is_nsfw BOOLEAN DEFAULT FALSE,
level INTEGER DEFAULT 0,
permalink TEXT NOT NULL,
pinned TEXT,
post_id INTEGER,
replies TEXT, -- Storing as JSON; consider relational integrity and querying needs.
reports TEXT, -- Storing as JSON; same considerations as 'replies'.
score INTEGER DEFAULT 0,
upvotes INTEGER DEFAULT 0
);