forked from TencentBlueKing/bk-job
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: 异常通知的收敛/抑制能力 TencentBlueKing#205
SQL改造成幂等语句
- Loading branch information
wadema
committed
Sep 13, 2021
1 parent
9929d4d
commit 1979d25
Showing
1 changed file
with
39 additions
and
3 deletions.
There are no files selected for viewing
42 changes: 39 additions & 3 deletions
42
support-files/sql/job-crontab/0003_job_crontab_20210909-1000_V3.4.0.0_mysql.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,42 @@ | ||
use job_crontab; | ||
|
||
SET NAMES utf8mb4; | ||
USE job_crontab; | ||
|
||
ALTER TABLE `job_crontab`.`cron_job` ADD COLUMN `last_execute_error_code` bigint(20) UNSIGNED NULL DEFAULT NULL AFTER `last_execute_status`; | ||
use job_crontab; | ||
|
||
SET NAMES utf8mb4; | ||
|
||
DROP PROCEDURE IF EXISTS job_schema_update; | ||
|
||
DELIMITER <JOB_UBF> | ||
|
||
CREATE PROCEDURE job_schema_update() | ||
BEGIN | ||
|
||
DECLARE db VARCHAR(100); | ||
SET AUTOCOMMIT = 0; | ||
SELECT DATABASE() INTO db; | ||
|
||
IF NOT EXISTS(SELECT 1 | ||
FROM information_schema.COLUMNS | ||
WHERE TABLE_SCHEMA = db | ||
AND TABLE_NAME = 'cron_job' | ||
AND COLUMN_NAME = 'last_execute_error_code') THEN | ||
ALTER TABLE cron_job ADD COLUMN `last_execute_error_code` bigint(20) UNSIGNED NULL DEFAULT NULL AFTER `last_execute_status`; | ||
END IF; | ||
|
||
IF NOT EXISTS(SELECT 1 | ||
FROM information_schema.COLUMNS | ||
WHERE TABLE_SCHEMA = db | ||
AND TABLE_NAME = 'cron_job' | ||
AND COLUMN_NAME = 'last_execute_error_count') THEN | ||
ALTER TABLE cron_job ADD COLUMN `last_execute_error_count` int(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `last_execute_error_code`; | ||
END IF; | ||
|
||
COMMIT; | ||
END <JOB_UBF> | ||
DELIMITER ; | ||
COMMIT; | ||
CALL job_schema_update(); | ||
|
||
ALTER TABLE `job_crontab`.`cron_job` ADD COLUMN `last_execute_error_count` int(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `last_execute_error_code`; | ||
DROP PROCEDURE IF EXISTS job_schema_update; |