-- ============================================
-- DISABLE RLS: Nosso Supabase não precisa de RLS
-- Segurança é do Supabase externo
-- ============================================

-- Desabilitar RLS em todas as tabelas de mensagens
ALTER TABLE conversations DISABLE ROW LEVEL SECURITY;
ALTER TABLE messages DISABLE ROW LEVEL SECURITY;
ALTER TABLE user_presence DISABLE ROW LEVEL SECURITY;
ALTER TABLE message_attachments DISABLE ROW LEVEL SECURITY;
ALTER TABLE message_notifications DISABLE ROW LEVEL SECURITY;

-- Dropar todas as políticas existentes
DROP POLICY IF EXISTS "Users can view own conversations" ON conversations;
DROP POLICY IF EXISTS "Users can create own conversations" ON conversations;
DROP POLICY IF EXISTS "Doctors can view their conversations" ON conversations;
DROP POLICY IF EXISTS "Patients can view their conversations" ON conversations;
DROP POLICY IF EXISTS "Users can view messages in own conversations" ON messages;
DROP POLICY IF EXISTS "Users can send messages in own conversations" ON messages;
DROP POLICY IF EXISTS "Users can update own messages" ON messages;
DROP POLICY IF EXISTS "Doctors can view their messages" ON messages;
DROP POLICY IF EXISTS "Patients can view their messages" ON messages;
DROP POLICY IF EXISTS "Users can view all presence" ON user_presence;
DROP POLICY IF EXISTS "Users can update own presence" ON user_presence;
DROP POLICY IF EXISTS "Users can insert own presence" ON user_presence;
DROP POLICY IF EXISTS "Users can upsert own presence" ON user_presence;
DROP POLICY IF EXISTS "Users can view attachments in own conversations" ON message_attachments;
DROP POLICY IF EXISTS "Users can upload attachments" ON message_attachments;
DROP POLICY IF EXISTS "Users can view own notifications" ON message_notifications;
DROP POLICY IF EXISTS "Users can update own notifications" ON message_notifications;
