premium_subscriptions table

The premium_subscriptions table in the Reddit Clone Database Schema schema has 10 columns, keyed by id, with 2 foreign keys to users.

source records whether premium was bought, gifted or granted by an award, which matters because only a purchased subscription can be refunded and only a recurring one can be cancelled.

Columns (10)

Columns of the premium_subscriptions table
ColumnTypeConstraintsDescription
iduuidprimary key
user_iduuidnot null, references users.id
planpremium_plannot null
statussubscription_statusnot null
gifted_byuuidreferences users.id
sourcepremium_sourcenot null
started_attimestamptznot null
current_period_endtimestamptz
cancel_at_period_endbooleannot null
canceled_attimestamptz

Indexes (2)

  • (user_id, status)
  • (status, current_period_end)

Relationships

  • premium_subscriptions.user_id references users.id
  • premium_subscriptions.gifted_by references users.id