diff --git a/src/main/resources/scripts/rwa-4667_update_completion_process.sql b/src/main/resources/scripts/rwa-4667_update_completion_process.sql new file mode 100644 index 0000000000..eab695b42a --- /dev/null +++ b/src/main/resources/scripts/rwa-4667_update_completion_process.sql @@ -0,0 +1,27 @@ +--Connect to main database +select count(*) from cft_task_db.tasks where jurisdiction = 'SSCS' and state in ('COMPLETED','TERMINATED') and termination_reason = 'completed'; +-- 8 + +--Create a backup of all the task's and copy to rollback script +create table IF NOT EXISTS cft_task_db.sscs_completed_tasks_ids_backup AS +select task_id from cft_task_db.tasks where jurisdiction = 'SSCS' and state in ('COMPLETED','TERMINATED') and termination_reason = 'completed'; + +-- Check count of records in backup table +select count(*) from cft_task_db.sscs_completed_tasks_ids_backup; +-- 8 + +update cft_task_db.tasks set termination_reason = 'RWA-4667' where jurisdiction = 'SSCS' and state in ('COMPLETED','TERMINATED') and termination_reason = 'completed'; +-- Updated Rows = 8 + +-- Verify the update +select count(*) from cft_task_db.tasks where jurisdiction = 'SSCS' and state in ('COMPLETED','TERMINATED') and termination_reason = 'completed'; +-- 0 + +-- Verify the new termination reason +select count(*) from cft_task_db.tasks where jurisdiction = 'SSCS' and state in ('COMPLETED','TERMINATED') and termination_reason = 'RWA-4667'; +-- 8 + +-- Drop the backup table if not needed +drop table if exists cft_task_db.sscs_completed_tasks_ids_backup; + + diff --git a/src/main/resources/scripts/rwa-4667_update_completion_process_rollback.sql b/src/main/resources/scripts/rwa-4667_update_completion_process_rollback.sql new file mode 100644 index 0000000000..a313d0b223 --- /dev/null +++ b/src/main/resources/scripts/rwa-4667_update_completion_process_rollback.sql @@ -0,0 +1,14 @@ +--check count of rows in backup table +select count(*) from cft_task_db.sscs_completed_tasks_ids_backup where jurisdiction = 'SSCS' and state in ('COMPLETED','TERMINATED') and termination_reason = 'completed'; +-- 8 + +update cft_task_db.tasks set termination_reason = 'completed' where task_id in (select task_id from cft_task_db.cft_task_db.sscs_completed_tasks_ids_backup); +-- Updated Rows = 8 + +-- Verify the update +select count(*) from cft_task_db.tasks where jurisdiction = 'SSCS' and state in ('COMPLETED','TERMINATED') and termination_reason = 'RWA-4667'; +-- 0 + +--Drop the backup table if not needed +drop table if exists cft_task_db.sscs_completed_tasks_ids_backup; +