| 1 |
CREATE TABLE posts ( |
| 2 |
id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| 3 |
thread_id UUID NOT NULL REFERENCES threads(id) ON DELETE CASCADE, |
| 4 |
author_id UUID NOT NULL REFERENCES users(mnw_account_id), |
| 5 |
body_markdown TEXT NOT NULL, |
| 6 |
body_html TEXT NOT NULL, |
| 7 |
parent_post_id UUID REFERENCES posts(id) ON DELETE SET NULL, |
| 8 |
created_at TIMESTAMPTZ NOT NULL DEFAULT now(), |
| 9 |
edited_at TIMESTAMPTZ |
| 10 |
); |
| 11 |
|
| 12 |
CREATE INDEX idx_posts_thread ON posts (thread_id, created_at); |
| 13 |
CREATE INDEX idx_posts_author ON posts (author_id); |
| 14 |
|