Offers Database Schema

Database table and enum for offers

Enum

offer_status

CREATE TYPE "public"."offer_status" AS ENUM(
  'PENDING',
  'ACCEPTED',
  'REJECTED',
  'COUNTERED'
);

Table: offers

ColumnTypeNullableDefaultDescription
idtextNOT NULLnanoid()Primary key
seller_account_idtextNOT NULLFK to account.id (seller)
buyer_account_idtextNOT NULLFK to account.id (buyer)
campaign_descriptiontextNOT NULLFree-text campaign description
campaign_typestext[]NOT NULL'{}'Chip selections (e.g. Radio ads, Billboards)
script_texttextNULLRadio ad script (if applicable)
usage_typestext[]NOT NULL'{}'Where content will be used
custom_usagetextNULLFree-text custom usage
wants_sharingbooleanNULLWhether buyer wants social sharing bundle
sharing_descriptiontextNULLSharing bundle details
offer_amount_centintegerNOT NULLPrice offered in cents
counter_amount_centintegerNULLSeller's counter price (when COUNTERED)
counter_notetextNULLSeller's counter message
statusoffer_statusNOT NULL'PENDING'Current status
deleted_attimestamptzNULLSoft delete
created_attimestamptzNOT NULLnow()Creation time
updated_attimestamptzNOT NULLnow()Last update

Indexes

  • offers_seller_idx on seller_account_id
  • offers_buyer_idx on buyer_account_id
  • offers_status_idx on status

Foreign Keys

  • seller_account_idaccount.id
  • buyer_account_idaccount.id

Migrations

  • packages/db/drizzle/0016_moaning_risque.sql — Initial offers table
  • packages/db/drizzle/0017_offers_buyer_account.sql — Replace buyer_email/buyer_name with buyer_account_id

Generate new migrations with:

cd packages/db && npx drizzle-kit generate

Apply migrations with:

cd packages/db && pnpm db:migrate

(Do not use db:push per project rules.)