Skip to Content
Trips Enjoy
Data Model (ERD)Domains

Coupons

Tables and relationships for the coupons domain.

Part of the data model; conventions and base columns are documented there.

coupons

(Base +) FR-CPN-01 to FR-CPN-08

ColumnTypeNotes
codeVARCHAR(40)Unique with deleted_at (case-insensitive)
creator_type_idBIGINT FK lookupscoupon_creator: admin, organization, driver, photographer
creator_user_idBIGINT FK users
organization_idBIGINT FK organizations NULLScope for organization coupons
scope_user_idBIGINT FK users NULLScope for driver or photographer coupons
market_idBIGINT FK markets NULLNull means all markets (admin only)
discount_type_idBIGINT FK lookupsdiscount_type: fixed, percent, program_specific, free_program, first_booking, minimum_spend
value_minorBIGINT NULLFixed amount
value_bpINT NULLPercentage in basis points
currency_codeCHAR(3) NULL
min_spend_minorBIGINT NULL
usage_limitINT NULL
per_user_limitINTDefault 1
used_countINT
valid_from, valid_untilTIMESTAMPTZ
audience_idBIGINT FK lookupscoupon_audience: public, targeted
is_stackableBOOLEAN
status_idBIGINT FK lookupscoupon_status: draft, active, paused, expired, exhausted, revoked

coupon_programs (Base +): coupon_id FK, program_id FK.

coupon_audiences (Base +): coupon_id FK, user_id FK NULL, segment_code VARCHAR(40) NULL.

coupon_redemptions (Base +): coupon_id FK, booking_id FK, user_id FK, organization_id, discount_minor BIGINT, currency_code, status_id FK lookups (redemption_status: applied, confirmed, reversed), reversed_at.

abuse_flags (Base +) D-216, D-217: subject_type_id FK lookups (flag_subject: coupon, user, booking, deal), subject_id BIGINT, rule_code VARCHAR(60), details JSONB, status_id FK lookups (flag_status: open, reviewed_ok, actioned), review_due_at (2 working days), reviewed_by FK users NULL.

On this page