-- 回滚前将 conflict 归并为 failed，避免恢复旧约束失败。
UPDATE tb_integration_log SET result = 'failed' WHERE result = 'conflict';

ALTER TABLE tb_integration_log
    DROP CONSTRAINT IF EXISTS ck_integration_log_result;

ALTER TABLE tb_integration_log
    ADD CONSTRAINT ck_integration_log_result CHECK (result IN (
        'pending', 'success', 'failed', 'unknown', 'not_found', 'invalid_payload',
        'ignored', 'merged', 'rate_limited', 'completed', 'cancelled'
    ));
