INSERT INTO `system` (`category`, `key`, `value`, `type`, `desc`, `created_at`, `updated_at`)
SELECT 'verify_code',
       'ExpireTime',
       COALESCE(MAX(CASE WHEN `key` = 'VerifyCodeExpireTime' THEN `value` END), '900'),
       'int',
       'Verify code expire time (legacy)',
       NOW(3),
       NOW(3)
FROM `system`
WHERE `category` = 'verify_code'
ON DUPLICATE KEY UPDATE
    `value` = VALUES(`value`),
    `type` = VALUES(`type`),
    `desc` = VALUES(`desc`),
    `updated_at` = VALUES(`updated_at`);

INSERT INTO `system` (`category`, `key`, `value`, `type`, `desc`, `created_at`, `updated_at`)
SELECT 'verify_code',
       'Limit',
       COALESCE(MAX(CASE WHEN `key` = 'VerifyCodeLimit' THEN `value` END), '15'),
       'int',
       'Verify code limit (legacy)',
       NOW(3),
       NOW(3)
FROM `system`
WHERE `category` = 'verify_code'
ON DUPLICATE KEY UPDATE
    `value` = VALUES(`value`),
    `type` = VALUES(`type`),
    `desc` = VALUES(`desc`),
    `updated_at` = VALUES(`updated_at`);

INSERT INTO `system` (`category`, `key`, `value`, `type`, `desc`, `created_at`, `updated_at`)
SELECT 'verify_code',
       'Interval',
       COALESCE(MAX(CASE WHEN `key` = 'VerifyCodeInterval' THEN `value` END), '60'),
       'int',
       'Verify code interval (legacy)',
       NOW(3),
       NOW(3)
FROM `system`
WHERE `category` = 'verify_code'
ON DUPLICATE KEY UPDATE
    `value` = VALUES(`value`),
    `type` = VALUES(`type`),
    `desc` = VALUES(`desc`),
    `updated_at` = VALUES(`updated_at`);
