Correção de erro 500 em mensagens (UUID), criação de tabela messages e tratamento defensivo no front-end para evitar crashes
This commit is contained in:
17
create_messages_table.sql
Normal file
17
create_messages_table.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- Criar tabela de mensagens no schema gpi
|
||||
CREATE TABLE IF NOT EXISTS gpi.messages (
|
||||
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||
organization_id uuid REFERENCES gpi.organizations(id) ON DELETE CASCADE,
|
||||
from_user_id uuid REFERENCES gpi.users(id) ON DELETE SET NULL,
|
||||
to_user_id uuid REFERENCES gpi.users(id) ON DELETE SET NULL,
|
||||
message text NOT NULL,
|
||||
is_read boolean DEFAULT false,
|
||||
read_at timestamp with time zone,
|
||||
is_archived boolean DEFAULT false,
|
||||
is_deleted_by_recipient boolean DEFAULT false,
|
||||
created_at timestamp with time zone DEFAULT now(),
|
||||
updated_at timestamp with time zone DEFAULT now()
|
||||
);
|
||||
|
||||
-- Permissões para as roles do Supabase
|
||||
GRANT ALL ON gpi.messages TO postgres, anon, authenticated, service_role;
|
||||
Reference in New Issue
Block a user