28 lines
1.3 KiB
MySQL
28 lines
1.3 KiB
MySQL
|
|
-- Run once per database BEFORE deploying the workflow progress changes.
|
||
|
|
-- Idempotent on MySQL; existing successful executions are normalized to 100.
|
||
|
|
-- Historical partial progress cannot be reconstructed reliably from node IDs.
|
||
|
|
SET @progress_column_exists = (
|
||
|
|
SELECT COUNT(*) FROM information_schema.columns
|
||
|
|
WHERE table_schema = DATABASE() AND table_name = 'te_task_inst' AND column_name = 'progress'
|
||
|
|
);
|
||
|
|
SET @progress_ddl = IF(@progress_column_exists = 0,
|
||
|
|
'ALTER TABLE te_task_inst ADD COLUMN progress DECIMAL(5,2) NOT NULL DEFAULT 0 COMMENT ''Workflow work progress, 0..100''',
|
||
|
|
'SELECT 1');
|
||
|
|
PREPARE progress_stmt FROM @progress_ddl;
|
||
|
|
EXECUTE progress_stmt;
|
||
|
|
DEALLOCATE PREPARE progress_stmt;
|
||
|
|
|
||
|
|
UPDATE te_task_inst SET progress = 100 WHERE status = '0' AND (progress IS NULL OR progress <> 100);
|
||
|
|
|
||
|
|
-- Some deployments do not install the Aima module.
|
||
|
|
SET @aima_progress_exists = (
|
||
|
|
SELECT COUNT(*) FROM information_schema.columns
|
||
|
|
WHERE table_schema = DATABASE() AND table_name = 'aima_task_instance' AND column_name = 'progress'
|
||
|
|
);
|
||
|
|
SET @aima_backfill = IF(@aima_progress_exists > 0,
|
||
|
|
'UPDATE aima_task_instance SET progress = 100 WHERE status = 0 AND (progress IS NULL OR progress <> 100)',
|
||
|
|
'SELECT 1');
|
||
|
|
PREPARE aima_progress_stmt FROM @aima_backfill;
|
||
|
|
EXECUTE aima_progress_stmt;
|
||
|
|
DEALLOCATE PREPARE aima_progress_stmt;
|