Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOSIP-23258]Updated release scripts #479

Open
wants to merge 3 commits into
base: release-1.2.0.1-bkp
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion db_release_scripts/mosip_pms/pms_release_db_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ today=`date '+%d%m%Y_%H%M%S'`;
LOG="${LOG_PATH}${MOSIP_DB_NAME}-release-${release_version}-${today}.log"
touch $LOG

SERVICE=$(PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "select count(1) from pg_roles where rolname IN('sysadmin')";exit; > /dev/null)
SERVICE=$(PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -v dbport="'$DB_PORT'" -v dbhost="'$DB_SERVERIP'" -v dbuser="'$SU_USER'" -v dbpassword="'$SU_USER_PWD'" -t -c "select count(1) from pg_roles where rolname IN('sysadmin')";exit; > /dev/null)

if [ "$SERVICE" -eq 0 ] || [ "$SERVICE" -eq 1 ]
then
Expand Down
92 changes: 91 additions & 1 deletion db_release_scripts/mosip_pms/sql/1.2.0_pms-scripts_release.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,94 @@ ALTER TABLE pms.ftp_chip_detail ADD COLUMN approval_status character varying(36)
UPDATE pms.ftp_chip_detail SET approval_status='pending_cert_upload' where certificate_alias is null;
UPDATE pms.ftp_chip_detail SET approval_status='pending_approval' where certificate_alias is not null and is_active =false;
UPDATE pms.ftp_chip_detail SET approval_status='approved' where certificate_alias is not null and is_active = true;
ALTER TABLE pms.ftp_chip_detail ALTER COLUMN approval_status SET NOT NULL;
ALTER TABLE pms.ftp_chip_detail ALTER COLUMN approval_status SET NOT NULL;

INSERT INTO pms.policy_group (id,name,descr,user_id,is_active,cr_by,cr_dtimes,upd_by,upd_dtimes,is_deleted,del_dtimes)
VALUES('mpolicygroup-default-cert','mpolicygroup-default-cert','mpolicygroup-default-cert','superadmin',true,'superadmin',now(),'superadmin',now(),false,NULL);

INSERT INTO pms.partner (id,policy_group_id,name,address,contact_no,email_id,certificate_alias,user_id,partner_type_code,approval_status,is_active,cr_by,cr_dtimes,upd_by,upd_dtimes,is_deleted,del_dtimes,lang_code)
VALUES('mpartner-default-cert','mpolicygroup-default-cert','mpartner-default-cert','mpartner-default-cert','9232121212','[email protected]',NULL,'mpartner-default-cert','Internal_Partner','approved',true,'superadmin',now(),'superadmin',now(),false,NULL,NULL);

INSERT INTO pms.partner_h (id,eff_dtimes,policy_group_id,name,address,contact_no,email_id,certificate_alias,user_id,partner_type_code,approval_status,is_active,cr_by,cr_dtimes,upd_by,upd_dtimes,is_deleted,del_dtimes,lang_code)
VALUES('mpartner-default-cert',now(),'mpolicygroup-default-cert','mpartner-default-cert','mpartner-default-cert','9232121212','[email protected]',NULL,'mpartner-default-cert','Internal_Partner','approved',true,'superadmin',now(),'superadmin',now(),false,NULL,NULL);


INSERT INTO pms.auth_policy (id,policy_group_id,name,descr,policy_file_id,policy_type,"version",policy_schema,valid_from_date,valid_to_date,is_active,cr_by,cr_dtimes,upd_by,upd_dtimes,is_deleted,del_dtimes)
VALUES('mpolicy-default-cert','mpolicygroup-default-cert','mpolicy-default-cert','mpolicy-default-cert','{"shareableAttributes":[{"attributeName":"fullName","source":[{"attribute":"fullName"}],"encrypted":true},{"attributeName":"dateOfBirth","source":[{"attribute":"dateOfBirth"}],"encrypted":true},{"attributeName":"gender","source":[{"attribute":"gender"}],"encrypted":true},{"attributeName":"phone","source":[{"attribute":"phone"}],"encrypted":true},{"attributeName":"email","source":[{"attribute":"email"}],"encrypted":true},{"attributeName":"addressLine1","source":[{"attribute":"addressLine1"}],"encrypted":true},{"attributeName":"addressLine2","source":[{"attribute":"addressLine2"}],"encrypted":true},{"attributeName":"addressLine3","source":[{"attribute":"addressLine3"}],"encrypted":true},{"attributeName":"region","source":[{"attribute":"region"}],"encrypted":true},{"attributeName":"province","source":[{"attribute":"province"}],"encrypted":true},{"attributeName":"city","source":[{"attribute":"city"}],"encrypted":true},{"attributeName":"postalCode","source":[{"attribute":"postalCode"}],"encrypted":true},{"attributeName":"individualBiometrics","group":"CBEFF","source":[{"attribute":"individualBiometrics"}],"encrypted":true,"format":"extraction"}],"dataSharePolicies":{"typeOfShare":"Data Share","validForInMinutes":"30","transactionsAllowed":"2","encryptionType":"none","shareDomain":"datashare.datashare","source":"ID Repository"}}','DataShare','1','https://schemas.mosip.io/v1/auth-policy',now(),now()+interval '12 years',true,'admin',now(),'admin',now(),false,NULL);

INSERT INTO pms.partner_policy_request (id,part_id,policy_id,request_datetimes,request_detail,status_code,cr_by,cr_dtimes,upd_by,upd_dtimes,is_deleted,del_dtimes)
VALUES('mpartner_policy_cert_req','mpartner-default-cert','mpolicy-default-cert',now(),'mpolicy-default-cert','approved','admin',now(),'admin',now(),NULL,NULL);

INSERT INTO pms.partner_policy (policy_api_key,part_id,policy_id,valid_from_datetime,valid_to_datetime,is_active,cr_by,cr_dtimes,upd_by,upd_dtimes,is_deleted,del_dtimes,"label")
VALUES('mpolicy_part_cert_api','mpartner-default-cert','mpolicy-default-cert',now(),now()+interval '12 years',true,'admin',now(),'admin',now(),false,NULL,'mpolicy_part_cert_api');


CREATE extension dblink;

SELECT dblink_connect('auth_device_conn', 'dbname=mosip_authdevice port=':dbport' host=':dbhost' user=':dbuser' password=':dbpassword'');

INSERT INTO device_detail
SELECT *
FROM dblink('auth_device_conn','SELECT id, dprovider_id, dtype_code, dstype_code, make, model, partner_org_name, approval_status, is_active, cr_by, cr_dtimes, upd_by, upd_dtimes, is_deleted, del_dtimes FROM device_detail') AS (id varchar, dprovider_id varchar, dtype_code varchar, dstype_code varchar, make varchar, model varchar, partner_org_name varchar, approval_status varchar, is_active bool, cr_by varchar, cr_dtimes timestamp, upd_by varchar, upd_dtimes timestamp, is_deleted bool, del_dtimes timestamp);

INSERT INTO secure_biometric_interface
SELECT *
FROM dblink('auth_device_conn','SELECT id, sw_binary_hash, sw_version, sw_cr_dtimes, sw_expiry_dtimes, approval_status, is_active, cr_by, cr_dtimes, upd_by, upd_dtimes, is_deleted, del_dtimes, provider_id, partner_org_name FROM secure_biometric_interface') AS (id varchar, sw_binary_hash bytea, sw_version varchar, sw_cr_dtimes timestamp, sw_expiry_dtimes timestamp, approval_status varchar, is_active bool, cr_by varchar, cr_dtimes timestamp, upd_by varchar, upd_dtimes timestamp, is_deleted bool, del_dtimes timestamp, provider_id varchar, partner_org_name varchar);

INSERT INTO secure_biometric_interface_h
SELECT *
FROM dblink('auth_device_conn','SELECT id, sw_binary_hash, sw_version, sw_cr_dtimes, sw_expiry_dtimes, approval_status, is_active, cr_by, cr_dtimes, upd_by, upd_dtimes, is_deleted, del_dtimes, eff_dtimes, provider_id, partner_org_name FROM secure_biometric_interface_h') AS(id varchar, sw_binary_hash bytea, sw_version varchar, sw_cr_dtimes timestamp, sw_expiry_dtimes timestamp, approval_status varchar, is_active bool, cr_by varchar, cr_dtimes timestamp, upd_by varchar, upd_dtimes timestamp, is_deleted bool, del_dtimes timestamp, eff_dtimes timestamp, provider_id varchar, partner_org_name varchar);

INSERT INTO device_detail_sbi
SELECT *
FROM dblink('auh_device_conn','select dd.dprovider_id,dd.partner_org_name,dd.id,id,is_active,cr_by,cr_dtimes,upd_by,upd_dtimes,is_deleted,del_dtimes from secure_biometric_interface inner join device_detail dd where device_detail_id = dd.id') AS(dprovider_id varchar, partner_org_name varchar, device_detail_id varchar, sbi_id varchar, is_active bool, cr_by varchar, cr_dtimes timestamp, upd_by varchar, upd_dtimes timestamp, is_deleted bool, del_dtimes timestamp);

INSERT INTO ftp_chip_detail
SELECT id,
foundational_trust_provider_id,
make,
model,
certificate_alias,
partner_org_name,
is_active,
cr_by,
cr_dtimes,
upd_by,
upd_dtimes,
is_deleted,
del_dtimes
FROM dblink('auth_device_conn', 'select id, foundational_trust_provider_id, make, model, certificate_alias, partner_org_name, is_active, cr_by, cr_dtimes, upd_by, upd_dtimes, is_deleted, del_dtimes from ftp_chip_detail') AS(id varchar, foundational_trust_provider_id varchar, make varchar, model varchar, certificate_alias varchar, partner_org_name varchar, is_active bool, cr_by varchar, cr_dtimes timestamp, upd_by varchar, upd_dtimes timestamp, is_deleted bool, del_dtimes timestamp);

SELECT dblink_connect('reg_device_conn', 'dbname=mosip_regdevice port=':dbport' host=':dbhost' user=':dbuser' password=':dbpassword'');

INSERT INTO device_detail
SELECT *
FROM dblink('reg_device_conn','SELECT id, dprovider_id, dtype_code, dstype_code, make, model, partner_org_name, approval_status, is_active, cr_by, cr_dtimes, upd_by, upd_dtimes, is_deleted, del_dtimes FROM device_detail') AS (id varchar, dprovider_id varchar, dtype_code varchar, dstype_code varchar, make varchar, model varchar, partner_org_name varchar, approval_status varchar, is_active bool, cr_by varchar, cr_dtimes timestamp, upd_by varchar, upd_dtimes timestamp, is_deleted bool, del_dtimes timestamp);

INSERT INTO secure_biometric_interface
SELECT *
FROM dblink('reg_device_conn','SELECT id, sw_binary_hash, sw_version, sw_cr_dtimes, sw_expiry_dtimes, approval_status, is_active, cr_by, cr_dtimes, upd_by, upd_dtimes, is_deleted, del_dtimes, provider_id, partner_org_name FROM secure_biometric_interface') AS (id varchar, sw_binary_hash bytea, sw_version varchar, sw_cr_dtimes timestamp, sw_expiry_dtimes timestamp, approval_status varchar, is_active bool, cr_by varchar, cr_dtimes timestamp, upd_by varchar, upd_dtimes timestamp, is_deleted bool, del_dtimes timestamp, provider_id varchar, partner_org_name varchar);

INSERT INTO secure_biometric_interface_h
SELECT *
FROM dblink('reg_device_conn','SELECT id, sw_binary_hash, sw_version, sw_cr_dtimes, sw_expiry_dtimes, approval_status, is_active, cr_by, cr_dtimes, upd_by, upd_dtimes, is_deleted, del_dtimes, eff_dtimes, provider_id, partner_org_name FROM secure_biometric_interface_h') AS(id varchar, sw_binary_hash bytea, sw_version varchar, sw_cr_dtimes timestamp, sw_expiry_dtimes timestamp, approval_status varchar, is_active bool, cr_by varchar, cr_dtimes timestamp, upd_by varchar, upd_dtimes timestamp, is_deleted bool, del_dtimes timestamp, eff_dtimes timestamp, provider_id varchar, partner_org_name varchar);

INSERT INTO device_detail_sbi
SELECT *
FROM dblink('reg_device_conn','select dd.dprovider_id,dd.partner_org_name,dd.id,id,is_active,cr_by,cr_dtimes,upd_by,upd_dtimes,is_deleted,del_dtimes from secure_biometric_interface inner join device_detail dd where device_detail_id = dd.id') AS(dprovider_id varchar, partner_org_name varchar, device_detail_id varchar, sbi_id varchar, is_active bool, cr_by varchar, cr_dtimes timestamp, upd_by varchar, upd_dtimes timestamp, is_deleted bool, del_dtimes timestamp);

INSERT INTO ftp_chip_detail
SELECT id,
foundational_trust_provider_id,
make,
model,
certificate_alias,
partner_org_name,
is_active,
cr_by,
cr_dtimes,
upd_by,
upd_dtimes,
is_deleted,
del_dtimes
FROM dblink('reg_device_conn', 'select id, foundational_trust_provider_id, make, model, certificate_alias, partner_org_name, is_active, cr_by, cr_dtimes, upd_by, upd_dtimes, is_deleted, del_dtimes from ftp_chip_detail') AS(id varchar, foundational_trust_provider_id varchar, make varchar, model varchar, certificate_alias varchar, partner_org_name varchar, is_active bool, cr_by varchar, cr_dtimes timestamp, upd_by varchar, upd_dtimes timestamp, is_deleted bool, del_dtimes timestamp);
24 changes: 24 additions & 0 deletions db_release_scripts/mosip_pms/sql/1.2.0_pms-scripts_revoke.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- -------------------------------------------------------------------------------------------------
-- Database Name: mosip_pms
-- Release Version : 1.2.0
-- Purpose : Revoking Database Alter deployement done for release in PMS DB.
-- Create By : Nagarjuna K
-- Created Date : Aug-2022
--
-- Modified Date Modified By Comments / Remarks
-- -------------------------------------------------------------------------------------------------

\c mosip_pms sysadmin

DROP TABLE IF EXISTS pms.device_detail;
DROP TABLE IF EXISTS pms.device_detail_sbi;
DROP TABLE IF EXISTS pms.ftp_chip_detail;
DROP TABLE IF EXISTS pms.reg_device_sub_type;
DROP TABLE IF EXISTS pms.reg_device_type;
DROP TABLE IF EXISTS pms.secure_biometric_interface;
DROP TABLE IF EXISTS pms.secure_biometric_interface_h;

ALTER TABLE pms.partner_policy DROP COLUMN label;
ALTER TABLE pms.partner DROP COLUMN lang_code;
ALTER TABLE pms.partner_h DROP COLUMN lang_code;