-- NordSafe EHS: Microsoft 365 / SharePoint fields on Companies
-- Run on existing databases after deploying the updated Sequelize model.

ALTER TABLE `Companies`
  ADD COLUMN `tenantId` VARCHAR(255) NULL COMMENT 'Azure AD tenant ID (tid)' AFTER `subscriptionType`,
  ADD COLUMN `msAccessToken` TEXT NULL COMMENT 'Encrypted Microsoft Graph access token' AFTER `tenantId`,
  ADD COLUMN `msRefreshToken` TEXT NULL COMMENT 'Encrypted Microsoft refresh token' AFTER `msAccessToken`,
  ADD COLUMN `msTokenExpiresAt` DATETIME NULL AFTER `msRefreshToken`,
  ADD COLUMN `msSharepointSiteId` VARCHAR(255) NULL AFTER `msTokenExpiresAt`,
  ADD COLUMN `msConnected` TINYINT(1) NOT NULL DEFAULT 0 AFTER `msSharepointSiteId`;
