-- Bootstrap schema hubee_wpp (monolito FilmeLab)
-- Projeto: uqhdmvlcfluebabbtvpd
-- Histórico WhatsApp do Hubee (Evolution / middleware). Independente do schema hubee CRM.

CREATE SCHEMA IF NOT EXISTS hubee_wpp;

GRANT USAGE ON SCHEMA hubee_wpp TO anon, authenticated, service_role;
GRANT ALL ON ALL TABLES IN SCHEMA hubee_wpp TO service_role;
GRANT ALL ON ALL ROUTINES IN SCHEMA hubee_wpp TO service_role;
GRANT ALL ON ALL SEQUENCES IN SCHEMA hubee_wpp TO service_role;

ALTER DEFAULT PRIVILEGES IN SCHEMA hubee_wpp
  GRANT ALL ON TABLES TO service_role;
ALTER DEFAULT PRIVILEGES IN SCHEMA hubee_wpp
  GRANT ALL ON ROUTINES TO service_role;
ALTER DEFAULT PRIVILEGES IN SCHEMA hubee_wpp
  GRANT ALL ON SEQUENCES TO service_role;

COMMENT ON SCHEMA hubee_wpp IS
  'Hubee WhatsApp — histórico de mensagens (Evolution + imports TXT); CRM em schema hubee';
