-- Create plans table
CREATE TABLE IF NOT EXISTS plans (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name VARCHAR(255) NOT NULL,
    slug VARCHAR(100) NOT NULL UNIQUE,
    description TEXT,
    min_users INTEGER NOT NULL DEFAULT 1,
    max_users INTEGER NOT NULL DEFAULT 30, -- -1 means unlimited
    monthly_price NUMERIC(10, 2),
    annual_price NUMERIC(10, 2),
    features TEXT[] NOT NULL DEFAULT '{}',
    differentiators TEXT[] NOT NULL DEFAULT '{}',
    storage_gb INTEGER NOT NULL DEFAULT 1,
    is_active BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Add indexes
CREATE INDEX idx_plans_slug ON plans(slug);
CREATE INDEX idx_plans_is_active ON plans(is_active);

-- Add comments
COMMENT ON TABLE plans IS 'Subscription plans for agencies';
COMMENT ON COLUMN plans.max_users IS '-1 means unlimited users';
