-- API Anahtarları Tablosu
CREATE TABLE IF NOT EXISTS public.admin_api_keys (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    key TEXT NOT NULL UNIQUE,
    value TEXT NOT NULL,
    description TEXT,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT now(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT now()
);

-- RLS Etkinleştir
ALTER TABLE public.admin_api_keys ENABLE ROW LEVEL SECURITY;

-- Politikalar
-- use is_admin() instead of is_admin(auth.uid()) as per definition
CREATE POLICY "Admins have full access to api keys" ON public.admin_api_keys
    FOR ALL TO authenticated
    USING (is_admin());
