-- Migration 029: Solo plan + annual_price column on plans table
-- Adds annual_price_aud_cents and sends_per_month to plans; inserts Solo free tier.
-- Columns were partially added in a failed first run; ALTER is wrapped safely.

-- Add columns (migration runner ensures this runs only once)
ALTER TABLE plans
    ADD COLUMN annual_price_aud_cents INT UNSIGNED NOT NULL DEFAULT 0
        AFTER price_aud_cents,
    ADD COLUMN sends_per_month INT UNSIGNED NOT NULL DEFAULT 0
        AFTER annual_price_aud_cents;

-- Backfill annual prices (monthly * 10 = 2 months free)
UPDATE plans SET annual_price_aud_cents = price_aud_cents * 10 WHERE tier != 'solo';

-- Insert Solo free tier if it doesn't exist
INSERT IGNORE INTO plans (slug, name, tier, price_aud_cents, annual_price_aud_cents, sends_per_month, created_at)
VALUES ('solo', 'Solo', 'solo', 0, 0, 50, NOW());
