/* =========================================================
   PRIMEIRO ACESSO + MAIA | DMS Desk
   Execute apos o modulo Portal Cliente ja estar aplicado.
   ========================================================= */

SET @db = DATABASE();

SELECT COUNT(*) INTO @existe
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'contatos' AND COLUMN_NAME = 'token_ativacao_expira_em';
SET @sql = IF(@existe = 0,
    'ALTER TABLE contatos ADD COLUMN token_ativacao_expira_em DATETIME NULL AFTER token_ativacao',
    'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
