subreddit_bans table
The subreddit_bans table in the Reddit Clone Database Schema schema has 12 columns, keyed by id, with 5 foreign keys to subreddits, users and subreddit_rules. 1 column in ban_appeals references it.
A ban is a row with an expiry, never a boolean. expires_at null is permanent, lifted_at records an early unban, and both together mean the sanction history survives an appeal. mod_note is private to moderators; message_to_user is what the person actually receives.
Columns (12)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| subreddit_id | uuid | not null, references subreddits.id | |
| user_id | uuid | not null, references users.id | |
| banned_by | uuid | not null, references users.id | |
| rule_id | uuid | references subreddit_rules.id | |
| reason | varchar(500) | not null | |
| mod_note | varchar(1000) | ||
| message_to_user | varchar(1000) | ||
| starts_at | timestamptz | not null | |
| expires_at | timestamptz | ||
| lifted_at | timestamptz | ||
| lifted_by | uuid | references users.id |
Indexes (2)
(subreddit_id, user_id, expires_at)(user_id)
Relationships
subreddit_bans.subreddit_idreferencessubreddits.idsubreddit_bans.user_idreferencesusers.idsubreddit_bans.banned_byreferencesusers.idsubreddit_bans.rule_idreferencessubreddit_rules.idsubreddit_bans.lifted_byreferencesusers.idban_appeals.subreddit_ban_idreferencessubreddit_bans