content_revisions table
The content_revisions table in the Reddit Clone Database Schema schema has 8 columns, keyed by id, with 1 foreign key to users.
Append-only edit history shared by posts, comments and wiki pages. The polymorphic pair is deliberate: three near-identical history tables would be worse, and nothing cascades from here anyway.
Columns (8)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| content_type | content_type | not null | |
| content_id | uuid | not null | |
| editor_id | uuid | references users.id | |
| revision_number | smallint | not null | |
| body_md | text | not null | |
| edit_reason | varchar(255) | ||
| created_at | timestamptz | not null |
Indexes (2)
(content_type, content_id, revision_number)unique(editor_id, created_at)
Relationships
content_revisions.editor_idreferencesusers.id