--- add-type-to-clients

ALTER TABLE clients ADD type VARCHAR(64);

UPDATE clients SET type='integrated';

ALTER TABLE clients ALTER COLUMN type VARCHAR(64) NOT NULL;

DROP INDEX clients_integration_id_uniq ON clients;

ALTER TABLE clients ALTER COLUMN integration_id VARCHAR(255);

CREATE UNIQUE INDEX clients_integration_id_uniq
  ON clients (integration_id)
  WHERE integration_id IS NOT NULL;

ALTER TABLE clients ADD telegram_id BIGINT;

CREATE UNIQUE INDEX clients_telegram_id_uniq ON clients(telegram_id) WHERE telegram_id IS NOT NULL;


