posts table
The posts table in the Forum Database Schema schema has 11 columns, keyed by id, with 3 foreign keys to topics, users and posts. 5 columns in post_revisions, votes, topic_subscriptions, reports and 1 more reference it.
is_first_post marks the opening body of the thread, so the topic row never has to carry text. deleted_at is a soft delete so replies below it do not orphan.
Columns (11)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| topic_id | uuid | not null, references topics.id | |
| author_id | uuid | not null, references users.id | |
| reply_to_post_id | uuid | references posts.id | |
| body | text | not null | |
| vote_score | integer | not null | |
| is_first_post | boolean | not null | |
| edit_count | smallint | not null | |
| created_at | timestamptz | not null | |
| edited_at | timestamptz | ||
| deleted_at | timestamptz |
Indexes (2)
(topic_id, created_at)(author_id, created_at)
Relationships
posts.topic_idreferencestopics.idposts.author_idreferencesusers.idposts.reply_to_post_idreferencesposts.idpost_revisions.post_idreferencespostsvotes.post_idreferencespoststopic_subscriptions.last_read_post_idreferencespostsreports.post_idreferencespostsmoderation_actions.target_post_idreferencesposts