ALTER TABLE gateway_security_event_connections
  ADD COLUMN IF NOT EXISTS management_client_id text,
  ADD COLUMN IF NOT EXISTS management_credential_ref text;

ALTER TABLE gateway_security_event_connections
  ADD CONSTRAINT gateway_security_event_management_credential_pair CHECK (
    (management_client_id IS NULL AND management_credential_ref IS NULL) OR
    (management_client_id IS NOT NULL AND management_credential_ref IS NOT NULL)
  );
