-- ============================================================
-- HeardCheck — Billing Phase Migration
-- Run: mysql -u heardcheck -p heardcheck_db < billing_upgrade.sql
-- ============================================================

USE heardcheck_db;

-- Add subscription columns to restaurant_settings
ALTER TABLE restaurant_settings
  ADD COLUMN subscription_plan ENUM('free','premium_monthly','premium_annual') NOT NULL DEFAULT 'free' AFTER restaurant_id,
  ADD COLUMN subscription_status ENUM('active','cancelled','expired') NOT NULL DEFAULT 'active' AFTER subscription_plan,
  ADD COLUMN subscription_expires DATETIME DEFAULT NULL AFTER subscription_status,
  ADD COLUMN original_transaction_id VARCHAR(255) DEFAULT NULL AFTER subscription_expires,
  ADD COLUMN receipt_data TEXT DEFAULT NULL AFTER original_transaction_id,
  ADD COLUMN updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
