Add unified post storage (#3)

Adds one post creation path for roots and replies, recursive thread loading, body-only updates, root listings, and root-only voting across PostgreSQL and the in-memory store.

Co-authored-by: codegirl-007 <s.raide@gmail.com>
This commit was merged in pull request #3.
This commit is contained in:
2026-08-27 07:43:25 +00:00
committed by codegirl007
parent c5ef15ae1f
commit e86c2072ea
11 changed files with 1764 additions and 30 deletions
+7 -4
View File
@@ -50,13 +50,13 @@ CREATE TABLE IF NOT EXISTS posts (
body TEXT NOT NULL,
city TEXT NOT NULL DEFAULT '',
post_date TEXT NOT NULL DEFAULT '',
hidden INTEGER NOT NULL DEFAULT 0,
post_state TEXT NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
CHECK (
CONSTRAINT posts_shape_check CHECK (
(parent_id IS NULL AND title <> '' AND post_date <> '')
OR
(parent_id IS NOT NULL AND title = '' AND city = '' AND post_date = '' AND hidden = 0)
(parent_id IS NOT NULL AND title = '' AND city = '' AND post_date = '')
)
);
@@ -64,7 +64,7 @@ CREATE INDEX IF NOT EXISTS idx_posts_parent_created
ON posts(parent_id, created_at, id);
CREATE INDEX IF NOT EXISTS idx_posts_root_date
ON posts(post_date, hidden)
ON posts(post_date, post_state)
WHERE parent_id IS NULL;
CREATE TABLE IF NOT EXISTS post_votes (
@@ -74,6 +74,9 @@ CREATE TABLE IF NOT EXISTS post_votes (
PRIMARY KEY (user_id, post_id)
);
CREATE INDEX IF NOT EXISTS idx_post_votes_post_id
ON post_votes(post_id);
CREATE TABLE IF NOT EXISTS sessions (
token TEXT PRIMARY KEY,
data BYTEA NOT NULL,