drafts table
The drafts table in the Reddit Clone Database Schema schema has 12 columns, keyed by id, with 3 foreign keys to users, subreddits and flairs. 1 column in scheduled_posts references it.
A draft is not an unpublished post. It carries no scores, no counters and no subreddit requirement, which is why it is its own table rather than a status on posts.
Columns (12)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| author_id | uuid | not null, references users.id | |
| subreddit_id | uuid | references subreddits.id | |
| kind | post_kind | not null | |
| title | varchar(300) | ||
| body_md | text | ||
| url | varchar(2000) | ||
| flair_id | uuid | references flairs.id | |
| is_nsfw | boolean | not null | |
| is_spoiler | boolean | not null | |
| created_at | timestamptz | not null | |
| updated_at | timestamptz | not null |
Indexes (1)
(author_id, updated_at)
Relationships
drafts.author_idreferencesusers.iddrafts.subreddit_idreferencessubreddits.iddrafts.flair_idreferencesflairs.idscheduled_posts.draft_idreferencesdrafts