Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/main/resources/scripts/rwa-4667_update_completion_process.sql
Original file line number Diff line number Diff line change
@@ -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;


Original file line number Diff line number Diff line change
@@ -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;