-- Migration: 019_add_company_subscription.sql
-- Description: Add Stripe subscription fields to companies table

ALTER TABLE companies ADD COLUMN IF NOT EXISTS stripe_customer_id VARCHAR(255);
ALTER TABLE companies ADD COLUMN IF NOT EXISTS subscription_plan VARCHAR(50) DEFAULT 'starter';
ALTER TABLE companies ADD COLUMN IF NOT EXISTS subscription_status VARCHAR(50) DEFAULT 'active';

-- Index for faster subscription queries
CREATE INDEX IF NOT EXISTS idx_companies_stripe_customer_id ON companies(stripe_customer_id);
CREATE INDEX IF NOT EXISTS idx_companies_subscription_plan ON companies(subscription_plan);
CREATE INDEX IF NOT EXISTS idx_companies_subscription_status ON companies(subscription_status);

COMMENT ON COLUMN companies.stripe_customer_id IS 'Stripe Customer ID';
COMMENT ON COLUMN companies.subscription_plan IS 'Current subscription plan (starter, professional, enterprise)';
COMMENT ON COLUMN companies.subscription_status IS 'Subscription status (active, past_due, canceled, trialing)';
