

-- Add company_id to existing tables
ALTER TABLE whatsapp_messages ADD COLUMN companyId INT NOT NULL DEFAULT 1;
ALTER TABLE whatsapp_sessions ADD COLUMN companyId INT NOT NULL DEFAULT 1;

-- Add foreign key constraints
ALTER TABLE whatsapp_messages ADD CONSTRAINT fk_messages_company 
  FOREIGN KEY (companyId) REFERENCES companies(id) ON DELETE CASCADE;

ALTER TABLE whatsapp_sessions ADD CONSTRAINT fk_sessions_company 
  FOREIGN KEY (companyId) REFERENCES companies(id) ON DELETE CASCADE;