From 5319332e7ef4cc140db7233199f1cb81c270f03c Mon Sep 17 00:00:00 2001 From: sudeep Date: Wed, 8 Jan 2025 18:44:15 +0530 Subject: [PATCH] MOSIP-32075 : DB attributes of PMS are hardcoded in db_scripts (sql scripts) Signed-off-by: sudeep --- .../mosip_pms/sql/1.1.4_release.sql | 2 +- .../mosip_pms/sql/1.1.4_revoke.sql | 2 +- .../sql/1.2.0.1-B2_pms-scripts_release.sql | 2 +- .../sql/1.2.0.1-B2_pms-scripts_revoke.sql | 2 +- .../sql/1.2.0.1-B2_to_1.2.0.1-B3_upgrade.sql | 2 +- .../sql/1.2.0.1-B2_to_1.2.0.1_revoke.sql | 2 +- .../sql/1.2.0.1-B3_to_1.2.0.1-B2_revoke.sql | 2 +- .../sql/1.2.0.1_to_1.2.0.1-B2_upgrade.sql | 2 +- .../sql/1.2.0.1_to_1.2.1.0_rollback.sql | 1 + .../sql/1.2.0.1_to_1.2.1.0_upgrade.sql | 1 + .../mosip_pms/sql/1.2.0_release.sql | 2 +- .../mosip_pms/sql/1.2.0_revoke.sql | 2 +- .../1.2.1.0_to_1.3.0-dp.1_rollback.sql.sql | 2 -- .../sql/1.2.1.0_to_1.3.0-dp.1_upgrade.sql.sql | 22 ------------------- .../sql/1.3.0-dp.1_to_1.3.0_rollback.sql | 2 +- .../sql/1.3.0-dp.1_to_1.3.0_upgrade.sql | 2 +- db_upgrade_scripts/mosip_pms/upgrade.sh | 18 +++++++-------- 17 files changed, 23 insertions(+), 45 deletions(-) delete mode 100644 db_upgrade_scripts/mosip_pms/sql/1.2.1.0_to_1.3.0-dp.1_rollback.sql.sql delete mode 100644 db_upgrade_scripts/mosip_pms/sql/1.2.1.0_to_1.3.0-dp.1_upgrade.sql.sql diff --git a/db_upgrade_scripts/mosip_pms/sql/1.1.4_release.sql b/db_upgrade_scripts/mosip_pms/sql/1.1.4_release.sql index 17001a8356..1539d4526a 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.1.4_release.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.1.4_release.sql @@ -8,7 +8,7 @@ -- Modified Date Modified By Comments / Remarks -- ------------------------------------------------------------------------------------------------- -\c mosip_pms sysadmin +\c :mosipdbname sysadmin \ir ../ddl/pms-partner_policy_credential_type.sql diff --git a/db_upgrade_scripts/mosip_pms/sql/1.1.4_revoke.sql b/db_upgrade_scripts/mosip_pms/sql/1.1.4_revoke.sql index b8943a4eb2..8e88c513e4 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.1.4_revoke.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.1.4_revoke.sql @@ -8,6 +8,6 @@ -- Modified Date Modified By Comments / Remarks -- ------------------------------------------------------------------------------------------------- -\c mosip_pms sysadmin +\c :mosipdbname sysadmin DROP TABLE IF EXISTS pms.partner_policy_credential_type; \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_pms-scripts_release.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_pms-scripts_release.sql index e8afd78198..f89583bd19 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_pms-scripts_release.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_pms-scripts_release.sql @@ -8,7 +8,7 @@ -- Modified Date Modified By Comments / Remarks -- ------------------------------------------------------------------------------------------------- -\c mosip_pms sysadmin +\c :mosipdbname sysadmin ALTER TABLE pms.partner ADD COLUMN logo_url character varying(256); diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_pms-scripts_revoke.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_pms-scripts_revoke.sql index 3657378299..1addff45bd 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_pms-scripts_revoke.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_pms-scripts_revoke.sql @@ -8,7 +8,7 @@ -- Modified Date Modified By Comments / Remarks -- ------------------------------------------------------------------------------------------------- -\c mosip_pms sysadmin +\c :mosipdbname sysadmin ALTER TABLE pms.partner DROP COLUMN logo_url; diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1-B3_upgrade.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1-B3_upgrade.sql index 2199a94e13..26d76f76b8 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1-B3_upgrade.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1-B3_upgrade.sql @@ -11,7 +11,7 @@ -\c mosip_pms sysadmin +\c :mosipdbname sysadmin INSERT INTO pms.partner_type (code,partner_description,is_policy_required,is_active,cr_by,cr_dtimes,upd_by,upd_dtimes,is_deleted,del_dtimes) VALUES ('Binding_Partner','Binding Partner',true,true,'superadmin',now(),NULL,NULL,false,NULL) ON CONFLICT (code) DO NOTHING; \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1_revoke.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1_revoke.sql index b45c93d4e5..39feb77c74 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1_revoke.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1_revoke.sql @@ -8,7 +8,7 @@ -- Modified Date Modified By Comments / Remarks -- ------------------------------------------------------------------------------------------------- -\c mosip_pms sysadmin +\c :mosipdbname sysadmin ALTER TABLE pms.partner DROP COLUMN logo_url; diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B3_to_1.2.0.1-B2_revoke.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B3_to_1.2.0.1-B2_revoke.sql index 41d5f029c1..ba2a2fad89 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B3_to_1.2.0.1-B2_revoke.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1-B3_to_1.2.0.1-B2_revoke.sql @@ -10,6 +10,6 @@ -\c mosip_pms sysadmin +\c :mosipdbname sysadmin DELETE FROM pms.partner_type WHERE code = 'Binding_Partner'; \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.0.1-B2_upgrade.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.0.1-B2_upgrade.sql index 4805e0c829..bb7e1f1e5a 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.0.1-B2_upgrade.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.0.1-B2_upgrade.sql @@ -8,7 +8,7 @@ -- Modified Date Modified By Comments / Remarks -- ------------------------------------------------------------------------------------------------- -\c mosip_pms sysadmin +\c :mosipdbname sysadmin ALTER TABLE pms.partner ADD COLUMN logo_url character varying(256); diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.1.0_rollback.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.1.0_rollback.sql index 099fc88413..dd21e4c0a2 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.1.0_rollback.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.1.0_rollback.sql @@ -1,3 +1,4 @@ +\c :mosipdbname sysadmin UPDATE pms.auth_policy SET policy_file_id='{"dataSharePolicies":{"typeOfShare":"direct","validForInMinutes":"30","transactionsAllowed":"2","encryptionType":"Partner Based","shareDomain":"datashare.datashare","source":"ID Repository"},"shareableAttributes":[{"attributeName":"fullName","source":[{"attribute":"fullName"}],"encrypted":true},{"attributeName":"dateOfBirth","source":[{"attribute":"dateOfBirth"}],"encrypted":false,"format":"YYYY"},{"attributeName":"gender","source":[{"attribute":"gender"}],"encrypted":false},{"attributeName":"phone","source":[{"attribute":"phone"}],"encrypted":false},{"attributeName":"email","source":[{"attribute":"email"}],"encrypted":false},{"attributeName":"addressLine1","source":[{"attribute":"addressLine1"}],"encrypted":false},{"attributeName":"addressLine2","source":[{"attribute":"addressLine2"}],"encrypted":false},{"attributeName":"addressLine3","source":[{"attribute":"addressLine3"}],"encrypted":false},{"attributeName":"region","source":[{"attribute":"region"}],"encrypted":false},{"attributeName":"province","source":[{"attribute":"province"}],"encrypted":false},{"attributeName":"city","source":[{"attribute":"city"}],"encrypted":false},{"attributeName":"UIN","source":[{"attribute":"UIN"}],"encrypted":false},{"attributeName":"PCN","source":[{"attribute":"VID","filter":[{"type":"PERPETUAL"}]}],"encrypted":false,"format":"RETRIEVE"},{"attributeName":"postalCode","source":[{"attribute":"postalCode"}],"encrypted":false},{"attributeName":"bestTwoFingers","group":"CBEFF","source":[{"attribute":"individualBiometrics","filter":[{"type":"Finger"}]}],"encrypted":false,"format":"bestTwoFingers"},{"attributeName":"Signature","source":[{"attribute":"proofOfAddress"}],"encrypted":false},{"attributeName":"biometrics","group":"CBEFF","source":[{"attribute":"individualBiometrics","filter":[{"type":"Face"},{"type":"Finger","subType":["Left Thumb","Right Thumb"]}]}],"encrypted":false,"format":"extraction"}]}' WHERE id='mpolicy-default-PDFCard'; \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.1.0_upgrade.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.1.0_upgrade.sql index 067818a8e9..2511cf295f 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.1.0_upgrade.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.2.0.1_to_1.2.1.0_upgrade.sql @@ -1,3 +1,4 @@ +\c :mosipdbname sysadmin UPDATE pms.auth_policy SET policy_file_id='{"dataSharePolicies":{"typeOfShare":"Data Share","validForInMinutes":"30","transactionsAllowed":"2","encryptionType":"Partner Based","shareDomain":"datashare.datashare","source":"ID Repository"},"shareableAttributes":[{"attributeName":"fullName","source":[{"attribute":"fullName","filter":[{"language":"eng"}]}],"encrypted":false},{"attributeName":"dateOfBirth","source":[{"attribute":"dateOfBirth"}],"encrypted":false},{"attributeName":"dob","source":[{"attribute":"dateOfBirth"}],"encrypted":false},{"attributeName":"gender","source":[{"attribute":"gender","filter":[{"language":"eng"}]}],"encrypted":false},{"attributeName":"phone","source":[{"attribute":"phone"}],"encrypted":false},{"attributeName":"email","source":[{"attribute":"email"}],"encrypted":false},{"attributeName":"addressLine1","source":[{"attribute":"addressLine1","filter":[{"language":"eng"}]}],"encrypted":false},{"attributeName":"addressLine2","source":[{"attribute":"addressLine2","filter":[{"language":"eng"}]}],"encrypted":false},{"attributeName":"addressLine3","source":[{"attribute":"addressLine3","filter":[{"language":"eng"}]}],"encrypted":false},{"attributeName":"region","source":[{"attribute":"region","filter":[{"language":"eng"}]}],"encrypted":false},{"attributeName":"province","source":[{"attribute":"province","filter":[{"language":"eng"}]}],"encrypted":false},{"attributeName":"city","source":[{"attribute":"city","filter":[{"language":"eng"}]}],"encrypted":false},{"attributeName":"UIN","source":[{"attribute":"UIN"}],"encrypted":false},{"attributeName":"postalCode","source":[{"attribute":"postalCode"}],"encrypted":false},{"attributeName":"biometrics","group":"CBEFF","source":[{"attribute":"individualBiometrics","filter":[{"type":"Face"},{"type":"Finger","subType":["Left Thumb","Right Thumb"]}]}],"encrypted":true,"format":"extraction"}]}' WHERE id='mpolicy-default-PDFCard'; \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.0_release.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.0_release.sql index a686efb8c4..98af00bae1 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.0_release.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.2.0_release.sql @@ -10,7 +10,7 @@ -- 15-07-2022 Nagarjuna K Merged 1.2.0.1 changes to 1.2.0 release patch -- ------------------------------------------------------------------------------------------------- -\c mosip_pms sysadmin +\c :mosipdbname sysadmin \ir ../ddl/pms-device_detail.sql diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.0_revoke.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.0_revoke.sql index c3b2632474..0eb6056b42 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.0_revoke.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.2.0_revoke.sql @@ -8,7 +8,7 @@ -- Modified Date Modified By Comments / Remarks -- -------------------------------------------------------------------------------------------------- -\c mosip_pms sysadmin +\c :mosipdbname sysadmin ALTER TABLE pms.device_detail DROP CONSTRAINT fk_devdtl_id; diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.1.0_to_1.3.0-dp.1_rollback.sql.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.1.0_to_1.3.0-dp.1_rollback.sql.sql deleted file mode 100644 index dae742a255..0000000000 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.1.0_to_1.3.0-dp.1_rollback.sql.sql +++ /dev/null @@ -1,2 +0,0 @@ --- user_details -DROP TABLE IF EXISTS pms.user_details; diff --git a/db_upgrade_scripts/mosip_pms/sql/1.2.1.0_to_1.3.0-dp.1_upgrade.sql.sql b/db_upgrade_scripts/mosip_pms/sql/1.2.1.0_to_1.3.0-dp.1_upgrade.sql.sql deleted file mode 100644 index 0f6a6147f4..0000000000 --- a/db_upgrade_scripts/mosip_pms/sql/1.2.1.0_to_1.3.0-dp.1_upgrade.sql.sql +++ /dev/null @@ -1,22 +0,0 @@ --- This table has consents of users. -CREATE TABLE pms.user_details( - id character varying(36) NOT NULL, - user_id character varying(64) NOT null, - consent_given character varying(36) NOT NULL DEFAULT 'NO', - consent_given_dtimes timestamp NOT NULL, - cr_dtimes timestamp NOT NULL, - cr_by character varying(64) NOT NULL, - upd_by character varying(64), - upd_dtimes timestamp, - CONSTRAINT user_details_pk PRIMARY KEY (id), - CONSTRAINT consent_given CHECK (consent_given IN ('YES', 'NO')) -); -COMMENT ON TABLE pms.user_details IS 'This table has consents of users.'; -COMMENT ON COLUMN pms.user_details.user_id IS 'User Id: user id of the user.'; -COMMENT ON COLUMN pms.user_details.id IS 'ID: Unique Id generated.'; -COMMENT ON COLUMN pms.user_details.consent_given_dtimes IS 'Consent given DateTimestamp : Date and Timestamp when the consent is given.'; -COMMENT ON COLUMN pms.user_details.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; -COMMENT ON COLUMN pms.user_details.cr_by IS 'Created By : ID or name of the user who create / insert record.'; -COMMENT ON COLUMN pms.user_details.consent_given IS 'Consent Given : Indicates whether consent has been given by the user.'; -COMMENT ON COLUMN pms.user_details.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; -COMMENT ON COLUMN pms.user_details.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; diff --git a/db_upgrade_scripts/mosip_pms/sql/1.3.0-dp.1_to_1.3.0_rollback.sql b/db_upgrade_scripts/mosip_pms/sql/1.3.0-dp.1_to_1.3.0_rollback.sql index bd9a7066d2..8868c432dc 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.3.0-dp.1_to_1.3.0_rollback.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.3.0-dp.1_to_1.3.0_rollback.sql @@ -7,7 +7,7 @@ -- -- Modified Date Modified By Comments / Remarks -- ------------------------------------------------------------------------------------------------- - +\c :mosipdbname sysadmin --Dropping unique index from pms.device_detail table DROP INDEX IF EXISTS pms.uk_devdtl_make_model_approval_status; diff --git a/db_upgrade_scripts/mosip_pms/sql/1.3.0-dp.1_to_1.3.0_upgrade.sql b/db_upgrade_scripts/mosip_pms/sql/1.3.0-dp.1_to_1.3.0_upgrade.sql index 773e81ae11..76a4d68c01 100644 --- a/db_upgrade_scripts/mosip_pms/sql/1.3.0-dp.1_to_1.3.0_upgrade.sql +++ b/db_upgrade_scripts/mosip_pms/sql/1.3.0-dp.1_to_1.3.0_upgrade.sql @@ -7,7 +7,7 @@ -- -- Modified Date Modified By Comments / Remarks -- ------------------------------------------------------------------------------------------------- - +\c :mosipdbname -- Dropping unique constraint from pms.device_detail table ALTER TABLE pms.device_detail DROP CONSTRAINT uk_devdtl_id; diff --git a/db_upgrade_scripts/mosip_pms/upgrade.sh b/db_upgrade_scripts/mosip_pms/upgrade.sh index c9ebad0fd8..f4e71e0548 100644 --- a/db_upgrade_scripts/mosip_pms/upgrade.sh +++ b/db_upgrade_scripts/mosip_pms/upgrade.sh @@ -34,13 +34,13 @@ if [ "$ACTION" == "upgrade" ]; then UPGRADE_SCRIPT_FILE="sql/${CURRENT_VERSION}_to_${UPGRADE_VERSION}_upgrade.sql" if [ -f "$UPGRADE_SCRIPT_FILE" ]; then echo "Executing upgrade script $UPGRADE_SCRIPT_FILE" - if [[ "$UPGRADE_VERSION" == "1.2.0.1-B1" && "$CURRENT_VERSION" == "1.1.5.5" ]]; then - echo "Creating dml directory." - mkdir dml - PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$SOURCE_DB1_NAME -a -b -f $SOURCE_DB1_SUPPORT_FILE - PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$SOURCE_DB2_NAME -a -b -f $SOURCE_DB2_SUPPORT_FILE - fi - PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f $UPGRADE_SCRIPT_FILE + if [[ "$UPGRADE_VERSION" == "1.2.0.1-B1" && "$CURRENT_VERSION" == "1.1.5.5" ]]; then + echo "Creating dml directory." + mkdir dml + PGPASSWORD=$SU_USER_PWD psql -v mosipdbname=$MOSIP_DB_NAME -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$SOURCE_DB1_NAME -a -b -f $SOURCE_DB1_SUPPORT_FILE + PGPASSWORD=$SU_USER_PWD psql -v mosipdbname=$MOSIP_DB_NAME -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$SOURCE_DB2_NAME -a -b -f $SOURCE_DB2_SUPPORT_FILE + fi + PGPASSWORD=$SU_USER_PWD psql -v mosipdbname=$MOSIP_DB_NAME -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f $UPGRADE_SCRIPT_FILE else echo "Upgrade script not found, exiting." exit 1 @@ -50,9 +50,9 @@ elif [ "$ACTION" == "rollback" ]; then REVOKE_SCRIPT_FILE="sql/${CURRENT_VERSION}_to_${UPGRADE_VERSION}_rollback.sql" if [ -f "$REVOKE_SCRIPT_FILE" ]; then echo "Executing rollback script $REVOKE_SCRIPT_FILE" - PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f $REVOKE_SCRIPT_FILE + PGPASSWORD=$SU_USER_PWD psql -v mosipdbname=$MOSIP_DB_NAME -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f $REVOKE_SCRIPT_FILE else - echo "rollback script not found, exiting." + echo "Rollback script not found, exiting." exit 1 fi else