slunch-factory-subscription

Tables (12)

billing_events

  • id — BIGINT — Primary key — NOT NULL
  • payment_key — VARCHAR(255) — NOT NULL
  • event_type — VARCHAR(64) — NOT NULL
  • status — VARCHAR(32)
  • received_at — DATETIME — NOT NULL
  • processed_at — DATETIME
  • raw_payload — JSON

billing_keys

  • id — BIGINT — Primary key — NOT NULL
  • user_id — BIGINT — Foreign key → users.id — NOT NULL
  • billing_key — VARCHAR(255) — NOT NULL
  • customer_key — VARCHAR(255) — NOT NULL
  • card_company — VARCHAR(255)
  • card_last4 — VARCHAR(255)
  • status — VARCHAR(20) — NOT NULL
  • issued_at — DATETIME — NOT NULL
  • is_default — BOOLEAN — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL

ingredients

  • id — BIGINT — Primary key — NOT NULL
  • code — VARCHAR(100) — NOT NULL
  • translations — JSON — NOT NULL
  • unit — VARCHAR(20) — NOT NULL
  • allergen_codes — JSON — NOT NULL
  • image_url — TEXT
  • is_active — BOOLEAN — NOT NULL
  • is_selectable — BOOLEAN — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL

orders

  • id — BIGINT — Primary key — NOT NULL
  • user_id — BIGINT — Foreign key → users.id — NOT NULL
  • order_number — VARCHAR(255) — NOT NULL
  • subscription_start_date — DATE — NOT NULL
  • subscription_end_date — DATE — NOT NULL
  • delivery_cycle — VARCHAR(255) — NOT NULL
  • order_date — DATETIME — NOT NULL
  • final_amount — DECIMAL(12,2) — NOT NULL
  • original_amount — DECIMAL(12,2) — NOT NULL
  • shipping_fee — DECIMAL(12,2) — NOT NULL
  • delivery_address — JSON — NOT NULL
  • discount_info — JSON — NOT NULL
  • product_snapshots — JSON — NOT NULL
  • status — VARCHAR(32) — NOT NULL
  • billing_key_id — BIGINT — Foreign key → billing_keys.id
  • next_billing_date — DATE
  • subscription_status — VARCHAR(20) — NOT NULL
  • next_retry_at — DATE
  • paused_at — DATETIME
  • canceled_at — DATETIME
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL

payments

  • id — BIGINT — Primary key — NOT NULL
  • order_id — BIGINT — Foreign key → orders.id — NOT NULL
  • billing_key_id — BIGINT — Foreign key → billing_keys.id — NOT NULL
  • cycle_no — INT — NOT NULL
  • amount — DECIMAL(12,2) — NOT NULL
  • status — VARCHAR(32) — NOT NULL
  • payment_key — VARCHAR(255)
  • approved_at — DATETIME
  • failure_reason — VARCHAR(255)
  • retry_count — INT — NOT NULL
  • shipping_date — DATE
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL

subscription_plan_items

  • id — BIGINT — Primary key — NOT NULL
  • plan_id — BIGINT — Foreign key → subscription_plans.id — NOT NULL
  • subscription_product_id — BIGINT — Foreign key → subscription_products.id — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL

subscription_plans

  • id — BIGINT — Primary key — NOT NULL
  • user_id — BIGINT — Foreign key → users.id — NOT NULL
  • delivery_cycle — VARCHAR(20) — NOT NULL
  • status — VARCHAR(20) — NOT NULL
  • started_at — DATETIME — NOT NULL
  • paused_at — DATETIME
  • cancelled_at — DATETIME
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL

subscription_product_images

  • id — BIGINT — Primary key — NOT NULL
  • subscription_product_id — BIGINT — Foreign key → subscription_products.id — NOT NULL
  • url — VARCHAR(500) — NOT NULL
  • alt_text — VARCHAR(300)
  • image_type — VARCHAR(20) — NOT NULL
  • sort_order — INT — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL

subscription_product_ingredients

  • id — BIGINT — Primary key — NOT NULL
  • subscription_product_id — BIGINT — Foreign key → subscription_products.id — NOT NULL
  • ingredient_id — BIGINT — Foreign key → ingredients.id — NOT NULL
  • amount — DECIMAL(10,2) — NOT NULL
  • unit — VARCHAR(10)
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL

subscription_products

  • id — BIGINT — Primary key — NOT NULL
  • code — VARCHAR(100) — NOT NULL
  • slug — VARCHAR(200) — NOT NULL
  • dietary_type — VARCHAR(30) — NOT NULL
  • health_goals — JSON — NOT NULL
  • is_spicy — BOOLEAN — NOT NULL
  • ingredient_cost — DECIMAL(12,2)
  • price — DECIMAL(12,2) — NOT NULL
  • translations — JSON — NOT NULL
  • tagline — TEXT
  • description — TEXT
  • cooking_tip — TEXT
  • selling_points — JSON — NOT NULL
  • product_info — JSON — NOT NULL
  • nutrition_info — JSON — NOT NULL
  • metadata — JSON — NOT NULL
  • is_active — BOOLEAN — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL

users

  • id — BIGINT — Primary key — NOT NULL
  • auth_user_id — VARCHAR(36) — NOT NULL
  • email — VARCHAR(200) — NOT NULL
  • name — VARCHAR(100) — NOT NULL
  • phone — VARCHAR(30)
  • birthday — DATE
  • locale — VARCHAR(10) — NOT NULL
  • marketing_sms — BOOLEAN — NOT NULL
  • marketing_email — BOOLEAN — NOT NULL
  • status — VARCHAR(32) — NOT NULL
  • profile_image_url — VARCHAR(500)
  • deletion_requested_at — DATETIME
  • address — JSON
  • auth_provider — TEXT — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL

wishlist_items

  • id — BIGINT — Primary key — NOT NULL
  • user_id — BIGINT — Foreign key → users.id — NOT NULL
  • subscription_product_id — BIGINT — Foreign key → subscription_products.id — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME — NOT NULL