scheduled_posts table
The scheduled_posts table in the Reddit Clone Database Schema schema has 10 columns, keyed by id, with 4 foreign keys to drafts, subreddits, users and posts.
The index on (status, scheduled_for) IS the scheduler: one range scan finds everything due. recurrence lets a mod team post a weekly thread without a cron job per community.
Columns (10)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| draft_id | uuid | references drafts.id | |
| subreddit_id | uuid | not null, references subreddits.id | |
| author_id | uuid | not null, references users.id | |
| scheduled_for | timestamptz | not null | |
| recurrence | recurrence_kind | not null | |
| status | schedule_status | not null | |
| published_post_id | uuid | references posts.id | |
| last_error | varchar(500) | ||
| created_at | timestamptz | not null |
Indexes (2)
(status, scheduled_for)(subreddit_id, scheduled_for)
Relationships
scheduled_posts.draft_idreferencesdrafts.idscheduled_posts.subreddit_idreferencessubreddits.idscheduled_posts.author_idreferencesusers.idscheduled_posts.published_post_idreferencesposts.id