subreddit_moderators table
The subreddit_moderators table in the Reddit Clone Database Schema schema has 14 columns, with 3 foreign keys to subreddits and users.
Permissions are columns, not an enum, because a moderator holds a SET of them. accepted_at null means the invite is still pending, so an invite and an appointment are the same row at two points in its life. position drives mod list order and therefore seniority in every escalation rule.
Columns (14)
| Column | Type | Constraints | Description |
|---|---|---|---|
| subreddit_id | uuid | not null, references subreddits.id | |
| user_id | uuid | not null, references users.id | |
| invited_by | uuid | references users.id | |
| is_full_permission | boolean | not null | |
| can_manage_posts | boolean | not null | |
| can_manage_users | boolean | not null | |
| can_manage_config | boolean | not null | |
| can_manage_flair | boolean | not null | |
| can_manage_mail | boolean | not null | |
| can_manage_wiki | boolean | not null | |
| can_manage_chat | boolean | not null | |
| position | smallint | not null | |
| invited_at | timestamptz | not null | |
| accepted_at | timestamptz |
Indexes (2)
(user_id)(subreddit_id, position)
Relationships
subreddit_moderators.subreddit_idreferencessubreddits.idsubreddit_moderators.user_idreferencesusers.idsubreddit_moderators.invited_byreferencesusers.id