
-- Add visibility array column to documents
ALTER TABLE public.documents ADD COLUMN IF NOT EXISTS visibility text[] NOT NULL DEFAULT '{}';

-- Migrate existing is_public=true documents to include 'public' in visibility
UPDATE public.documents SET visibility = ARRAY['public'] WHERE is_public = true AND visibility = '{}';
