-- Migration 114: Seller Stripe Connect accounts (v0.602)
-- Links users (sellers) to their Stripe Connect Express accounts

CREATE TABLE IF NOT EXISTS seller_stripe_accounts (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    stripe_account_id VARCHAR(255) NOT NULL,
    charges_enabled BOOLEAN DEFAULT FALSE,
    payouts_enabled BOOLEAN DEFAULT FALSE,
    onboarding_completed BOOLEAN DEFAULT FALSE,
    created_at TIMESTAMPTZ DEFAULT NOW(),
    updated_at TIMESTAMPTZ DEFAULT NOW(),
    CONSTRAINT uq_seller_stripe_user UNIQUE (user_id),
    CONSTRAINT uq_seller_stripe_account UNIQUE (stripe_account_id)
);

CREATE INDEX idx_seller_stripe_accounts_user ON seller_stripe_accounts(user_id);
