This commit is contained in:
Carlos Correia
2026-03-04 15:54:24 +00:00
parent b405cfb93b
commit ebca3cfdce
147 changed files with 9168 additions and 0 deletions

34
fix_users_table.sql Normal file
View File

@@ -0,0 +1,34 @@
-- Primeiro, remova qualquer trigger existente
DROP TRIGGER IF EXISTS on_auth_user_created;
-- Remova a função existente
DROP FUNCTION IF EXISTS public.handle_new_user();
-- Crie a função simplificada
CREATE OR REPLACE FUNCTION public.handle_new_user()
RETURNS TRIGGER AS $$
BEGIN
-- Insere o usuário na tabela users com os dados básicos
INSERT INTO public.users (id, name, email, created_at, updated_at)
VALUES (
NEW.id,
COALESCE(NEW.raw_user_meta_data->>'name', 'User'),
NEW.email,
NOW(),
NOW()
);
RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
-- Crie o trigger novamente
CREATE TRIGGER on_auth_user_created
AFTER INSERT ON auth.users
FOR EACH ROW
EXECUTE FUNCTION public.handle_new_user();
-- Verifique se a tabela users existe e está correta
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'users'
AND table_schema = 'public';