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)

Columns of the content_revisions table
ColumnTypeConstraintsDescription
iduuidprimary key
content_typecontent_typenot null
content_iduuidnot null
editor_iduuidreferences users.id
revision_numbersmallintnot null
body_mdtextnot null
edit_reasonvarchar(255)
created_attimestamptznot null

Indexes (2)

  • (content_type, content_id, revision_number) unique
  • (editor_id, created_at)

Relationships

  • content_revisions.editor_id references users.id