From 03d93bf5b83f121005a2d56a5d09b66efd2f2d66 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 7 Feb 2024 15:34:20 +0530 Subject: [PATCH] Updated db scripts to index refid but not otphash Signed-off-by: Loganathan Sekar --- .../common/service/repository/OtpTxnRepository.java | 7 ++----- db_scripts/mosip_ida/ddl/ida-otp_transaction.sql | 2 +- .../mosip_ida/sql/1.2.0.1-B5_to_1.2.0.1_rollback.sql | 5 +++++ .../mosip_ida/sql/1.2.0.1-B5_to_1.2.0.1_upgrade.sql | 5 +++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/repository/OtpTxnRepository.java b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/repository/OtpTxnRepository.java index 195ab19ce65..04baf478d10 100644 --- a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/repository/OtpTxnRepository.java +++ b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/repository/OtpTxnRepository.java @@ -13,14 +13,11 @@ public interface OtpTxnRepository extends BaseRepository { /** - * Find by otp hash and status code. + * Find first element by ref_id ordered by generated_dtimes in descending order. * - * @param otpHash the otp hash - * @param statusCode the status code + * @param refIdHash the ref id hash * @return the optional */ - Optional findByOtpHashAndStatusCode(String otpHash, String statusCode); - Optional findFirstByRefIdOrderByGeneratedDtimesDesc(String refIdHash); } diff --git a/db_scripts/mosip_ida/ddl/ida-otp_transaction.sql b/db_scripts/mosip_ida/ddl/ida-otp_transaction.sql index 8dc9662eb95..fdc483862cf 100644 --- a/db_scripts/mosip_ida/ddl/ida-otp_transaction.sql +++ b/db_scripts/mosip_ida/ddl/ida-otp_transaction.sql @@ -32,7 +32,7 @@ CREATE TABLE ida.otp_transaction( ); -- ddl-end -- --index section starts---- -CREATE INDEX ind_otphsh ON ida.otp_transaction (otp_hash,status_code); +CREATE INDEX ind_refid ON ida.otp_transaction (ref_id); --index section ends------ COMMENT ON TABLE ida.otp_transaction IS 'OTP Transaction: All OTP related data and validation details are maintained here for ID Authentication module.'; -- ddl-end -- diff --git a/db_upgrade_scripts/mosip_ida/sql/1.2.0.1-B5_to_1.2.0.1_rollback.sql b/db_upgrade_scripts/mosip_ida/sql/1.2.0.1-B5_to_1.2.0.1_rollback.sql index 1ea8a6e97f2..37b4fb58b16 100644 --- a/db_upgrade_scripts/mosip_ida/sql/1.2.0.1-B5_to_1.2.0.1_rollback.sql +++ b/db_upgrade_scripts/mosip_ida/sql/1.2.0.1-B5_to_1.2.0.1_rollback.sql @@ -1,3 +1,8 @@ \echo 'Upgrade Queries not required for the transition from 1.2.0.1-B5 to 1.2.0.1' ALTER TABLE ida.credential_event_store ALTER COLUMN credential_transaction_id type character varying(36); + +CREATE INDEX ind_otphsh ON ida.otp_transaction (otp_hash,status_code); + +DROP INDEX IF EXISTS ida.ind_refid; + diff --git a/db_upgrade_scripts/mosip_ida/sql/1.2.0.1-B5_to_1.2.0.1_upgrade.sql b/db_upgrade_scripts/mosip_ida/sql/1.2.0.1-B5_to_1.2.0.1_upgrade.sql index 36efab138ca..1e46a63bf46 100644 --- a/db_upgrade_scripts/mosip_ida/sql/1.2.0.1-B5_to_1.2.0.1_upgrade.sql +++ b/db_upgrade_scripts/mosip_ida/sql/1.2.0.1-B5_to_1.2.0.1_upgrade.sql @@ -1,3 +1,8 @@ \echo 'Upgrade Queries not required for transition from 1.2.0.1-B5 to 1.2.0.1' ALTER TABLE ida.credential_event_store ALTER COLUMN credential_transaction_id type character varying(64); + +DROP INDEX IF EXISTS ida.ind_otphsh; + +CREATE INDEX ind_refid ON ida.otp_transaction (ref_id); +