CREATE TABLE IF NOT EXISTS whatsapp_chat_atribuicoes (
  id SERIAL PRIMARY KEY,
  chat_id VARCHAR(255) NOT NULL,
  user_id SERIAL REFERENCES usuarios(id) ON DELETE CASCADE,
  area_id SERIAL REFERENCES areas(id) ON DELETE SET NULL,
  assigned_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
  UNIQUE(chat_id)
);
