From baaae62cedadf0dfbd4babad623fdd5a99a2276a Mon Sep 17 00:00:00 2001 From: himeshr Date: Wed, 18 Dec 2024 12:15:03 +0530 Subject: [PATCH] avniproject/avni-server#813 | Check BATCH_JOB_EXECUTION_PARAMS table exists before update to avoid test failure --- .../V1_347_1__SpringBatchSchemaUpgradeTo5.sql | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/avni-server-api/src/main/resources/db/migration/V1_347_1__SpringBatchSchemaUpgradeTo5.sql b/avni-server-api/src/main/resources/db/migration/V1_347_1__SpringBatchSchemaUpgradeTo5.sql index 5d2bed7d4..ea1c135e2 100644 --- a/avni-server-api/src/main/resources/db/migration/V1_347_1__SpringBatchSchemaUpgradeTo5.sql +++ b/avni-server-api/src/main/resources/db/migration/V1_347_1__SpringBatchSchemaUpgradeTo5.sql @@ -1,14 +1,25 @@ -update batch_job_execution_params bjep -set string_val = long_val::text -where type_cd = 'LONG'; - -update batch_job_execution_params bjep -set string_val = date_val::text -where type_cd = 'DATE'; - -update batch_job_execution_params bjep -set string_val = double_val::text -where type_cd = 'DOUBLE'; +DO +$$ + BEGIN + IF EXISTS + (SELECT 1 + FROM information_schema.tables + WHERE table_schema = 'public' + AND table_name = 'BATCH_JOB_EXECUTION_PARAMS' + ) + THEN + UPDATE BATCH_JOB_EXECUTION_PARAMS bjep + set string_val = long_val::text + where type_cd = 'LONG'; + UPDATE BATCH_JOB_EXECUTION_PARAMS bjep + set string_val = date_val::text + where type_cd = 'DATE'; + UPDATE BATCH_JOB_EXECUTION_PARAMS bjep + set string_val = double_val::text + where type_cd = 'DOUBLE'; + END IF; + END +$$; ALTER TABLE if exists BATCH_STEP_EXECUTION ADD CREATE_TIME TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00';