diff --git a/.circleci/config.yml b/.circleci/config.yml index 1d8dfba..a1acf0c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -41,10 +41,10 @@ build_steps: &build_steps command: | ./awsconfiguration.sh ${DEPLOY_ENV} source awsenvconf - - ./buildenv.sh -e ${DEPLOY_ENV} -b ${LOGICAL_ENV}-${APP_NAME}-consumer-deployvar - source buildenvvar - ./master_deploy.sh -d ECS -e ${DEPLOY_ENV} -t latest -s ${GLOBAL_ENV}-global-appvar,${LOGICAL_ENV}-${APP_NAME}-appvar -i postgres-ifx-processer + + # ./buildenv.sh -e ${DEPLOY_ENV} -b ${LOGICAL_ENV}-${APP_NAME}-consumer-deployvar + #source buildenvvar + #./master_deploy.sh -d ECS -e ${DEPLOY_ENV} -t latest -s ${GLOBAL_ENV}-global-appvar,${LOGICAL_ENV}-${APP_NAME}-appvar -i postgres-ifx-processer echo "Running Masterscript - deploy postgres-ifx-processer producer" if [ -e ${LOGICAL_ENV}-${APP_NAME}-consumer-deployvar.json ]; then sudo rm -vf ${LOGICAL_ENV}-${APP_NAME}-consumer-deployvar.json; fi @@ -58,11 +58,11 @@ build_steps: &build_steps source buildenvvar ./master_deploy.sh -d ECS -e ${DEPLOY_ENV} -t latest -s ${GLOBAL_ENV}-global-appvar,${LOGICAL_ENV}-${APP_NAME}-appvar -i postgres-ifx-processer - echo "Running Masterscript - deploy postgres-ifx-processer reconsiler1" - if [ -e ${LOGICAL_ENV}-${APP_NAME}-reconsiler1-deployvar.json ]; then sudo rm -vf ${LOGICAL_ENV}-${APP_NAME}-reconsiler1-deployvar.json; fi - ./buildenv.sh -e ${DEPLOY_ENV} -b ${LOGICAL_ENV}-${APP_NAME}-reconsiler1-deployvar - source buildenvvar - ./master_deploy.sh -d ECS -e ${DEPLOY_ENV} -t latest -s ${GLOBAL_ENV}-global-appvar,${LOGICAL_ENV}-${APP_NAME}-appvar -i postgres-ifx-processer + #echo "Running Masterscript - deploy postgres-ifx-processer reconsiler1" + #if [ -e ${LOGICAL_ENV}-${APP_NAME}-reconsiler1-deployvar.json ]; then sudo rm -vf ${LOGICAL_ENV}-${APP_NAME}-reconsiler1-deployvar.json; fi + #./buildenv.sh -e ${DEPLOY_ENV} -b ${LOGICAL_ENV}-${APP_NAME}-reconsiler1-deployvar + #source buildenvvar + #./master_deploy.sh -d ECS -e ${DEPLOY_ENV} -t latest -s ${GLOBAL_ENV}-global-appvar,${LOGICAL_ENV}-${APP_NAME}-appvar -i postgres-ifx-processer jobs: # Build & Deploy against development backend # diff --git a/config/default.js b/config/default.js index 5dbde50..0fc39a8 100644 --- a/config/default.js +++ b/config/default.js @@ -50,8 +50,8 @@ module.exports = { }, DYNAMODB: { - DYNAMODB_TABLE: process.env.DYNAMODB_TABLE || 'dev_pg_ifx_payload_sync' - DD_ElapsedTime: process.env.DD_ElapsedTime || 600000 + DYNAMODB_TABLE: process.env.DYNAMODB_TABLE || 'dev_pg_ifx_payload_sync', + DD_ElapsedTime: process.env.DD_ElapsedTime || 600000 }, AUTH0_URL: process.env.AUTH0_URL , diff --git a/informix-identity-trigger-proc.sql b/informix-identity-trigger-proc.sql new file mode 100644 index 0000000..21ed378 --- /dev/null +++ b/informix-identity-trigger-proc.sql @@ -0,0 +1,204 @@ +database common_oltp +DROP PROCEDURE proc_user_update(varchar,decimal); +DROP PROCEDURE proc_user_update; +CREATE PROCEDURE informix.proc_user_update( +new_handle varchar(50), +user_id decimal(10,0)) + if (USER != 'ifxsyncuser') then +UPDATE user SET handle_lower = lower(new_handle), modify_date = current WHERE user.user_id = user_id; +End if; +end procedure; +create procedure "informix".proc_user_update( +user_id DECIMAL(10,0), +old_first_name VARCHAR(64), +new_first_name VARCHAR(64), +old_last_name VARCHAR(64), +new_last_name VARCHAR(64), +old_handle VARCHAR(50), +new_handle VARCHAR(50), +old_status VARCHAR(3), +new_status VARCHAR(3), +old_activation_code VARCHAR(32), +new_activation_code VARCHAR(32), +old_middle_name VARCHAR(64), +new_middle_name VARCHAR(64), +old_timezone_id decimal(5,0), +new_timezone_id decimal(5,0) +) + + if ((old_first_name != new_first_name) or (old_last_name != new_last_name ) or (old_middle_name != new_middle_name )) then + insert into audit_user (column_name, old_value, new_value, +user_id) + values ('NAME', NVL(old_first_name, '') || ' ' || NVL(old_middle_name, '') || ' ' || NVL(old_last_name, ''), + NVL(new_first_name, '') || ' ' || NVL(new_middle_name, +'') || ' ' || NVL(new_last_name, ''), user_id); + End if; + + if (old_handle != new_handle) then + insert into audit_user (column_name, old_value, new_value, +user_id) + values ('HANDLE', old_handle, new_handle, user_id); + End If; + + if (old_status != new_status) then + insert into audit_user (column_name, old_value, new_value, +user_id) + values ('STATUS', old_status, new_status, user_id); + End If; + + if (old_activation_code != new_activation_code) then + insert into audit_user (column_name, old_value, new_value, +user_id) + values ('ACTIVATION_CODE', old_activation_code, new_activation_code, user_id); + End If; + + if (old_timezone_id != new_timezone_id) then + insert into audit_user (column_name, old_value, new_value, +user_id) + values ('TIMEZONE_ID', old_timezone_id, new_timezone_id, user_id); + End If; + if (USER != 'ifxsyncuser') then + UPDATE user SET handle_lower = lower(new_handle), modify_date = current WHERE user.user_id = user_id; + End if; +end procedure; + +DROP PROCEDURE informix.proc_email_update; +CREATE PROCEDURE informix.proc_email_update( +email_id decimal(10,0), +user_id DECIMAL(10,0), +old_email_type_id DECIMAL(5,0), +new_email_type_id DECIMAL(5,0), +old_address VARCHAR(100), +new_address VARCHAR(100), +old_primary_ind DECIMAL(1,0), +new_primary_ind DECIMAL(1,0), +old_status_id DECIMAL(3,0), +new_status_id DECIMAL(3,0) +) + + if (old_email_type_id != new_email_type_id) then + insert into audit_user (column_name, old_value, new_value, user_id) + values ('EMAIL_TYPE', old_email_type_id, new_email_type_id, user_id); + End If; + + if (old_status_id != new_status_id) then + insert into audit_user (column_name, old_value, new_value, user_id) + values ('EMAIL_STATUS', old_status_id, new_status_id, user_id); + End If; + + if (old_address != new_address) then + insert into audit_user (column_name, old_value, new_value, user_id) + values ('EMAIL_ADDRESS', old_address, new_address, user_id); + End If; + + if (old_primary_ind != new_primary_ind) then + insert into audit_user (column_name, old_value, new_value, user_id) + values ('EMAIL_PRIMARY_IND', old_primary_ind, new_primary_ind, user_id); + End If; + if (USER != 'ifxsyncuser') then + update email set modify_date = current where email.email_id = email_id; + End if; +end procedure; + + +database informixoltp +DROP PROCEDURE informix.proc_coder_update; +CREATE PROCEDURE informix.proc_coder_update( +v_oldcoder_id decimal(10,0), +v_oldquote varchar(255),v_newquote varchar (255), +v_oldlanguage_id decimal(3,0), v_newlanguage_id decimal(3,0), +v_oldcoder_type_id decimal(3,0), v_newcoder_type_id decimal(3,0), +v_oldcomp_country_code varchar(3), v_newcomp_country_code varchar(3) +) + + if (v_oldquote != v_newquote) then + insert into audit_coder (column_name, old_value, new_value, user_id) + values ('QUOTE', v_oldquote , v_newquote, v_oldcoder_id); + End if; + + if (v_oldcoder_type_id != v_newcoder_type_id) then + insert into audit_coder (column_name, old_value, new_value, user_id) + values ('CODER_TYPE', v_oldcoder_type_id , v_newcoder_type_id, v_oldcoder_id); + End if; + + if (v_oldlanguage_id != v_newlanguage_id) then + insert into audit_coder (column_name, old_value, new_value, user_id) + values ('LANGUAGE', v_oldlanguage_id , v_newlanguage_id, v_oldcoder_id); + End if; + + if (v_oldcomp_country_code != v_newcomp_country_code) then + insert into audit_coder (column_name, old_value, new_value, user_id) + values ('COMP_COUNTRY', v_oldcomp_country_code , v_newcomp_country_code, v_oldcoder_id); + End if; + + if (USER != 'ifxsyncuser') then + update coder set modify_date = current where coder_id = v_oldcoder_id; + End if; + +end procedure; + +database tcs_catalog; +DROP PROCEDURE proc_reliability_update; +CREATE PROCEDURE informix.proc_reliability_update( +p_user_id DECIMAL(10,0), +p_phase_id decimal(3,0), +old_rating decimal(5,4), +new_rating decimal(5,4) +) + + if (USER != 'ifxsyncuser') then + if (old_rating != new_rating) then + insert into user_reliability_audit (column_name, old_value, new_value, user_id, phase_id) + values ('RATING', old_rating, new_rating, p_user_id, p_phase_id); + End If; + + update user_reliability set modify_date = current where user_id = p_user_id and phase_id = p_phase_id; +End if; +end procedure; + +DROP PROCEDURE proc_rating_update; +CREATE PROCEDURE informix.proc_rating_update( +p_user_id DECIMAL(10,0), +p_phase_id decimal(3,0), +old_rating decimal(10,0), +new_rating decimal(10,0), +old_vol decimal(10,0), +new_vol decimal(10,0), +old_num_ratings decimal(5,0), +new_num_ratings decimal(5,0), +old_last_rated_project_id decimal(12,0), +new_last_rated_project_id decimal(12,0) +) + if (USER != 'ifxsyncuser') then + if (old_rating != new_rating) then + insert into user_rating_audit (column_name, old_value, new_value, user_id, phase_id) + values ('RATING', old_rating, new_rating, p_user_id, p_phase_id); + End If; + + if (old_vol != new_vol) then + insert into user_rating_audit (column_name, old_value, new_value, user_id, phase_id) + values ('VOL', old_vol, new_vol, p_user_id, p_phase_id); + End If; + + if (old_num_ratings != new_num_ratings) then + insert into user_rating_audit (column_name, old_value, new_value, user_id, phase_id) + values ('NUM_RATINGS', old_num_ratings, new_num_ratings, p_user_id, p_phase_id); + End If; + + if (old_last_rated_project_id != new_last_rated_project_id) then + insert into user_rating_audit (column_name, old_value, new_value, user_id, phase_id) + values ('LAST_RATED_PROJECT_ID', old_last_rated_project_id, new_last_rated_project_id, p_user_id, p_phase_id); + End If; + + update user_rating set mod_date_time = current where user_id = p_user_id and phase_id = p_phase_id; +End if; +end procedure; + +DROP PROCEDURE proc_contest_creation_update; +CREATE PROCEDURE informix.proc_contest_creation_update (create_user VARCHAR(64), old_project_status_id INT, new_project_status_id INT) +if (USER != 'ifxsyncuser') then + if (old_project_status_id != new_project_status_id and new_project_status_id == 1) then + insert into corona_event (corona_event_type_id,user_id) values (5, TO_NUMBER(create_user)); + end if; +End if; +end procedure; diff --git a/informix_triggers/tcs_catalog/01_project_tables_disables.sql b/informix_triggers/tcs_catalog/01_project_tables_disables.sql new file mode 100644 index 0000000..a85476b --- /dev/null +++ b/informix_triggers/tcs_catalog/01_project_tables_disables.sql @@ -0,0 +1,57 @@ +database tcs_catalog; +SET triggers informix.ifxpgsync_project_catalog_lu_insert disabled; SET triggers informix.ifxpgsync_project_catalog_lu_update disabled; SET triggers informix.ifxpgsync_project_catalog_lu_delete disabled; +SET triggers informix.ifxpgsync_project_category_lu_insert disabled; SET triggers informix.ifxpgsync_project_category_lu_update disabled; SET triggers informix.ifxpgsync_project_category_lu_delete disabled; +SET triggers informix.ifxpgsync_project_sub_category_lu_insert disabled; SET triggers informix.ifxpgsync_project_sub_category_lu_update disabled; SET triggers informix.ifxpgsync_project_sub_category_lu_delete disabled; +SET triggers informix.ifxpgsync_project_type_lu_insert disabled; SET triggers informix.ifxpgsync_project_type_lu_update disabled; SET triggers informix.ifxpgsync_project_type_lu_delete disabled; + +SET triggers informix.ifxpgsync_project_status_lu_insert disabled; SET triggers informix.ifxpgsync_project_status_lu_update disabled; SET triggers informix.ifxpgsync_project_status_lu_delete disabled; + +SET triggers informix.ifxpgsync_project_studio_specification_insert disabled; SET triggers informix.ifxpgsync_project_studio_specification_update disabled; SET triggers informix.ifxpgsync_project_studio_specification_delete disabled; + +SET triggers informix.ifxpgsync_project_mm_specification_insert disabled; SET triggers informix.ifxpgsync_project_mm_specification_update disabled; SET triggers informix.ifxpgsync_project_mm_specification_delete disabled; + +SET triggers informix.ifxpgsync_project_spec_insert disabled; SET triggers informix.ifxpgsync_project_spec_update disabled; SET triggers informix.ifxpgsync_project_spec_delete disabled; +SET triggers informix.ifxpgsync_copilot_contest_extra_info_insert disabled; SET triggers informix.ifxpgsync_copilot_contest_extra_info_update disabled; SET triggers informix.ifxpgsync_copilot_contest_extra_info_delete disabled; +SET triggers informix.ifxpgsync_contest_sale_insert disabled; SET triggers informix.ifxpgsync_contest_sale_update disabled; SET triggers informix.ifxpgsync_contest_sale_delete disabled; +SET triggers informix.ifxpgsync_contest_milestone_xref_insert disabled; SET triggers informix.ifxpgsync_contest_milestone_xref_update disabled; SET triggers informix.ifxpgsync_contest_milestone_xref_delete disabled; + +SET triggers informix.ifxpgsync_project_copilot_type_insert disabled; SET triggers informix.ifxpgsync_project_copilot_type_update disabled; SET triggers informix.ifxpgsync_project_copilot_type_delete disabled; +SET triggers informix.ifxpgsync_project_file_type_xref_insert disabled; SET triggers informix.ifxpgsync_project_file_type_xref_update disabled; SET triggers informix.ifxpgsync_project_file_type_xref_delete disabled; + +SET triggers informix.ifxpgsync_project_info_insert disabled; SET triggers informix.ifxpgsync_project_info_update disabled; SET triggers informix.ifxpgsync_project_info_delete disabled; +SET triggers informix.ifxpgsync_project_milestone_insert disabled; SET triggers informix.ifxpgsync_project_milestone_update disabled; SET triggers informix.ifxpgsync_project_milestone_delete disabled; +SET triggers informix.ifxpgsync_project_milestone_owner_insert disabled; SET triggers informix.ifxpgsync_project_milestone_owner_update disabled; SET triggers informix.ifxpgsync_project_milestone_owner_delete disabled; + +SET triggers informix.ifxpgsync_phase_criteria_insert disabled; SET triggers informix.ifxpgsync_phase_criteria_update disabled; SET triggers informix.ifxpgsync_phase_criteria_delete disabled; + +SET triggers informix.ifxpgsync_phase_criteria_type_lu_insert disabled; SET triggers informix.ifxpgsync_phase_criteria_type_lu_update disabled; SET triggers informix.ifxpgsync_phase_criteria_type_lu_delete disabled; +SET triggers informix.ifxpgsync_phase_dependency_insert disabled; SET triggers informix.ifxpgsync_phase_dependency_update disabled; SET triggers informix.ifxpgsync_phase_dependency_delete disabled; + +SET triggers informix.ifxpgsync_prize_insert disabled; SET triggers informix.ifxpgsync_prize_update disabled; SET triggers informix.ifxpgsync_prize_delete disabled; +SET triggers informix.ifxpgsync_project_platform_insert disabled; SET triggers informix.ifxpgsync_project_platform_update disabled; SET triggers informix.ifxpgsync_project_platform_delete disabled; + +SET triggers informix.ifxpgsync_project_insert disabled; SET triggers informix.ifxpgsync_project_update disabled; SET triggers informix.ifxpgsync_project_delete disabled; +SET triggers informix.ifxpgsync_project_phase_insert disabled; SET triggers informix.ifxpgsync_project_phase_update disabled; SET triggers informix.ifxpgsync_project_phase_delete disabled; +SET triggers informix.ifxpgsync_project_user_audit_insert disabled; SET triggers informix.ifxpgsync_project_user_audit_update disabled; SET triggers informix.ifxpgsync_project_user_audit_delete disabled; + +SET triggers informix.ifxpgsync_project_payment_adjustment_insert disabled; SET triggers informix.ifxpgsync_project_payment_adjustment_update disabled; SET triggers informix.ifxpgsync_project_payment_adjustment_delete disabled; +SET triggers informix.ifxpgsync_project_reliability_insert disabled; SET triggers informix.ifxpgsync_project_reliability_update disabled; SET triggers informix.ifxpgsync_project_reliability_delete disabled; +SET triggers informix.ifxpgsync_project_result_insert disabled; SET triggers informix.ifxpgsync_project_result_update disabled; SET triggers informix.ifxpgsync_project_result_delete disabled; + +SET triggers informix.ifxpgsync_late_deliverable_insert disabled; SET triggers informix.ifxpgsync_late_deliverable_update disabled; SET triggers informix.ifxpgsync_late_deliverable_delete disabled; +SET triggers informix.ifxpgsync_linked_project_xref_insert disabled; SET triggers informix.ifxpgsync_linked_project_xref_update disabled; +SET triggers informix.ifxpgsync_linked_project_xref_delete disabled; + +SET triggers informix.ifxpgsync_notification_insert disabled; SET triggers informix.ifxpgsync_notification_update disabled; SET triggers informix.ifxpgsync_notification_delete disabled; +SET triggers informix.ifxpgsync_review_insert disabled; SET triggers informix.ifxpgsync_review_update disabled; SET triggers informix.ifxpgsync_review_delete disabled; +SET triggers informix.ifxpgsync_reviewer_rating_insert disabled; SET triggers informix.ifxpgsync_reviewer_rating_update disabled; SET triggers informix.ifxpgsync_reviewer_rating_delete disabled; + + +SET triggers informix.ifxpgsync_review_feedback_insert disabled; SET triggers informix.ifxpgsync_review_feedback_update disabled; SET triggers informix.ifxpgsync_review_feedback_delete disabled; + +SET triggers informix.ifxpgsync_review_auction_insert disabled; SET triggers informix.ifxpgsync_review_auction_update disabled; SET triggers informix.ifxpgsync_review_auction_delete disabled; + +SET triggers informix.ifxpgsync_resource_insert disabled; SET triggers informix.ifxpgsync_resource_update disabled; SET triggers informix.ifxpgsync_resource_delete disabled; +SET triggers informix.ifxpgsync_software_competition_pipeline_info_insert disabled; SET triggers informix.ifxpgsync_software_competition_pipeline_info_update disabled; SET triggers informix.ifxpgsync_software_competition_pipeline_info_delete disabled; +SET triggers informix.ifxpgsync_team_header_insert disabled; SET triggers informix.ifxpgsync_team_header_update disabled; SET triggers informix.ifxpgsync_team_header_delete disabled; +SET triggers informix.ifxpgsync_upload_insert disabled; SET triggers informix.ifxpgsync_upload_update disabled; SET triggers informix.ifxpgsync_upload_delete disabled; diff --git a/pg-identity-func-trig-seq.sql b/pg-identity-func-trig-seq.sql index e7b5e6f..423ee1a 100644 --- a/pg-identity-func-trig-seq.sql +++ b/pg-identity-func-trig-seq.sql @@ -97,21 +97,29 @@ pguserval := (SELECT current_user); else column_value = '1'; end if; + when + column_name = 'social_email_verified' then + if column_value = 'false' then + column_value = 'f'; + else + column_value = 't'; + end if; when column_name = 'create_date' then column_value := (select to_char (column_value::timestamp, 'YYYY-MM-DD HH24:MI:SS.MS')); when column_name = 'modify_date' then column_value := (select to_char (column_value::timestamp, 'YYYY-MM-DD HH24:MI:SS.MS')); - -- when - -- column_name = 'achievement_date' then - --column_value := (select to_date (column_value, 'MM/DD/YYYY')); - --column_value := (select to_date (column_value)); - --when - --column_name = 'password' then - --column_value := regexp_replace(column_value, '\s', '', 'g'); - --column_value := regexp_replace(column_value, E'[\\n\\r]+', '\n\r', 'g'); - else + when + column_name = 'last_login' then + column_value := (select to_char (column_value::timestamp, 'YYYY-MM-DD HH24:MI:SS.MS')); + when + column_name = 'last_site_hit_date' then + column_value := (select to_char (column_value::timestamp, 'YYYY-MM-DD HH24:MI:SS.MS')); + when + column_name = 'corona_event_timestamp' then + column_value := (select to_char (column_value::timestamp, 'YYYY-MM-DD HH24:MI:SS.MS')); + else -- RAISE NOTICE ' not boolean'; end case; payload_items := array_append(payload_items, '"' || replace(column_name, '"', '\"') || '":"' || replace(column_value, '"', '\"') || '"'); @@ -119,7 +127,7 @@ pguserval := (SELECT current_user); --logtime := (select date_display_tz()); logtime := (SELECT to_char (now()::timestamptz at time zone 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS"Z"')); - payloadseqid := (select nextval('payloadsequence'::regclass)); + payloadseqid := (select nextval('common_oltp.payloadsequence'::regclass)); uniquecolumn := (SELECT c.column_name FROM information_schema.key_column_usage AS c @@ -155,11 +163,18 @@ pguserval := (SELECT current_user); END; $body$ LANGUAGE plpgsql +--CREATE TRIGGER "pg_email_trigger" +-- AFTER INSERT OR DELETE OR UPDATE ON email +-- FOR EACH ROW +-- EXECUTE PROCEDURE notify_trigger_common_oltp('user_id', 'email_id', 'email_type_id', 'address', 'primary_ind', 'status_id'); + CREATE TRIGGER "pg_email_trigger" AFTER INSERT OR DELETE OR UPDATE ON email FOR EACH ROW -EXECUTE PROCEDURE notify_trigger_common_oltp('user_id', 'email_id', 'email_type_id', 'address', 'primary_ind', 'status_id'); - +EXECUTE PROCEDURE notify_trigger_common_oltp('user_id', 'email_id', 'email_type_id', 'address', 'create_date', 'modify_date', 'primary_ind', 'status_id'); + + + CREATE TRIGGER "pg_security_user_trigger" AFTER INSERT OR DELETE OR UPDATE ON security_user FOR EACH ROW @@ -196,9 +211,70 @@ CREATE TRIGGER "pg_security_groups_trigger" FOR EACH ROW EXECUTE PROCEDURE notify_trigger_common_oltp('group_id', 'description', 'challenge_group_ind', 'create_user_id'); - + CREATE TRIGGER "pg_social_login_provider_trigger" +AFTER INSERT OR DELETE OR UPDATE ON social_login_provider +FOR EACH ROW +EXECUTE PROCEDURE notify_trigger_common_oltp('social_login_provider_id', 'name'); + +CREATE TRIGGER "pg_sso_login_provider_trigger" +AFTER INSERT OR DELETE OR UPDATE ON sso_login_provider +FOR EACH ROW +EXECUTE PROCEDURE notify_trigger_common_oltp('sso_login_provider_id', 'name','type','identify_email_enabled','identify_handle_enabled'); + +CREATE TRIGGER "pg_Country_trigger" +AFTER INSERT OR DELETE OR UPDATE ON Country +FOR EACH ROW +EXECUTE PROCEDURE notify_trigger_common_oltp('country_code', 'country_name','modify_date','participating','default_taxform_id','longitude','latitude','region','iso_name','iso_alpha2_code','iso_alpha3_code'); + +CREATE TRIGGER "pg_invalid_handles_trigger" +AFTER INSERT OR DELETE OR UPDATE ON invalid_handles +FOR EACH ROW +EXECUTE PROCEDURE notify_trigger_common_oltp('invalid_handle_id', 'invalid_handle'); + +CREATE TRIGGER "pg_achievement_type_lu_trigger" +AFTER INSERT OR DELETE OR UPDATE ON achievement_type_lu +FOR EACH ROW +EXECUTE PROCEDURE notify_trigger_common_oltp('achievement_type_id','achievement_type_desc'); + + + CREATE OR REPLACE FUNCTION "common_oltp"."proc_email_update" () RETURNS trigger + VOLATILE +AS $body$ +DECLARE +pguserval TEXT; +BEGIN + if (OLD.email_type_id != NEW.email_type_id) then + insert into common_oltp.audit_user (column_name, old_value, new_value, user_id) + values ('EMAIL_TYPE', OLD.email_type_id, NEW.email_type_id, OLD.user_id); + End If; + + if (OLD.status_id != NEW.status_id) then + insert into common_oltp.audit_user (column_name, old_value, new_value, user_id) + values ('EMAIL_STATUS', OLD.status_id, NEW.status_id, OLD.user_id); + End If; + + if (OLD.address != NEW.address) then + insert into common_oltp.audit_user (column_name, old_value, new_value, user_id) + values ('EMAIL_ADDRESS', OLD.address, NEW.address, OLD.user_id); + End If; + + if (OLD.primary_ind != NEW.primary_ind) then + insert into common_oltp.audit_user (column_name, old_value, new_value, user_id) + values ('EMAIL_PRIMARY_IND', OLD.primary_ind, NEW.primary_ind, OLD.user_id); + End If; - + pguserval := (SELECT current_user); + if pguserval != 'pgsyncuser' then + NEW.modify_date = current_timestamp; + end if; + + + RETURN NEW; +END; +$body$ LANGUAGE plpgsql + + ALTER SEQUENCE corona_event_corona_event_id_seq RESTART WITH 77770000; + CREATE SEQUENCE payloadsequence INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE; @@ -228,6 +304,8 @@ WITH 70100000 NO CYCLE; ADD COLUMN identify_handle_enabled BOOLEAN NOT NULL default true; SET search_path TO informixoltp; + +alter table payment_detail add column task_id numeric(10,0); CREATE OR REPLACE FUNCTION "informixoltp"."notify_trigger_informixoltp" () RETURNS trigger VOLATILE @@ -326,7 +404,7 @@ BEGIN END LOOP; --logtime := (select date_display_tz()); logtime := (SELECT to_char (now()::timestamptz at time zone 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS"Z"')); - payloadseqid := (select nextval('payloadsequence'::regclass)); + payloadseqid := (select nextval('common_oltp.payloadsequence'::regclass)); uniquecolumn := (SELECT c.column_name FROM information_schema.key_column_usage AS c @@ -367,12 +445,59 @@ CREATE TRIGGER "pg_algo_rating" FOR EACH ROW EXECUTE PROCEDURE notify_trigger_informixoltp('coder_id', 'rating', 'vol', 'round_id', 'num_ratings', 'algo_rating_type_id', 'modify_date'); +--CREATE TRIGGER "pg_coder" +-- AFTER INSERT OR DELETE OR UPDATE ON coder +-- FOR EACH ROW +-- EXECUTE PROCEDURE notify_trigger_informixoltp('coder_id', 'quote', 'coder_type_id', 'comp_country_code', 'display_quote', 'quote_location', 'quote_color', 'display_banner', 'banner_style'); CREATE TRIGGER "pg_coder" AFTER INSERT OR DELETE OR UPDATE ON coder FOR EACH ROW -EXECUTE PROCEDURE notify_trigger_informixoltp('coder_id', 'quote', 'coder_type_id', 'comp_country_code', 'display_quote', 'quote_location', 'quote_color', 'display_banner', 'banner_style'); +EXECUTE PROCEDURE notify_trigger_informixoltp('coder_id', 'member_since', 'quote', 'modify_date', 'language_id', 'coder_type_id', 'date_of_birth', 'home_country_code', 'comp_country_code', 'contact_date', 'display_quote', 'quote_location', 'quote_color', 'display_banner', 'banner_style'); + + +CREATE TRIGGER "pg_coder_referral_trigger" +AFTER INSERT OR DELETE OR UPDATE ON coder_referral +FOR EACH ROW +EXECUTE PROCEDURE notify_trigger_informixoltp('coder_id', 'referral_id','reference_id','other'); + + +CREATE OR REPLACE FUNCTION "informixoltp"."proc_coder_update" () RETURNS trigger + VOLATILE +AS $body$ +DECLARE + pguserval TEXT; +begin + if (OLD.quote != NEW.quote) then + insert into audit_coder (column_name, old_value, new_value, user_id) + values ('QUOTE', OLD.quote , NEW.quote, OLD.coder_id); + end if; + + if (OLD.coder_type_id != NEW.coder_type_id) then + insert into audit_coder (column_name, old_value, new_value, user_id) + values ('CODER_TYPE', OLD.coder_type_id , NEW.coder_type_id, OLD.coder_id); + end if; + if (OLD.language_id != NEW.language_id) then + insert into audit_coder (column_name, old_value, new_value, user_id) + values ('LANGUAGE', OLD.language_id , NEW.language_id, OLD.coder_id); + end if; + if (OLD.comp_country_code != NEW.comp_country_code) then + insert into audit_coder (column_name, old_value, new_value, user_id) + values ('COMP_COUNTRY', OLD.comp_country_code , NEW.comp_country_code, OLD.coder_id); + end if; + pguserval := (SELECT current_user); + if pguserval != 'pgsyncuser' then + -- RAISE info 'current_user'; + -- raise notice 'inside current_user : %', current_user; + --update coder set modify_date = current_timestamp where coder_id = OLD.coder_id; + NEW.modify_date = current_timestamp; + end if; + + return NEW; +end ; +$body$ LANGUAGE plpgsql + -GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA common_oltp,informixoltp, corporate_oltp,tcs_catalog, time_oltp TO coder; + GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA common_oltp,informixoltp, corporate_oltp,tcs_catalog, time_oltp TO coder; GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA common_oltp,informixoltp, corporate_oltp,tcs_catalog, time_oltp TO coder; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA common_oltp,informixoltp, corporate_oltp,tcs_catalog, time_oltp TO pgsyncuser; diff --git a/src/producer.js b/src/producer.js index 983de78..75e11a5 100644 --- a/src/producer.js +++ b/src/producer.js @@ -26,7 +26,15 @@ try { pgClient.on('notification', async (message) => { try { payloadcopy = "" + logger.debug('Entering producer 1') + logger.debug(message.toString()) + logger.debug('Entering producer 2') + logger.debug(message) + logger.debug('Entering producer 3') + logger.debug(JSON.stringify(message.payload)) + const payload = JSON.parse(message.payload) + payloadcopy = message const validTopicAndOriginator = (pgOptions.triggerTopics.includes(payload.topic)) && (pgOptions.triggerOriginators.includes(payload.originator)) // Check if valid topic and originator if (validTopicAndOriginator) { diff --git a/src/reconsiler-audit.js b/src/reconsiler-audit.js index 6604e68..4491fd1 100644 --- a/src/reconsiler-audit.js +++ b/src/reconsiler-audit.js @@ -24,7 +24,7 @@ async function setupPgClient() { rec_d_type = config.RECONSILER.RECONSILER_DURATION_TYPE var paramvalues = ['push-to-kafka',rec_d_start,rec_d_end]; sql1 = "select pgifx_sync_audit.seq_id, pgifx_sync_audit.payloadseqid,pgifx_sync_audit.auditdatetime ,pgifx_sync_audit.syncstatus, pgifx_sync_audit.payload from common_oltp.pgifx_sync_audit where pgifx_sync_audit.syncstatus =($1)" - sql2 = " and pgifx_sync_audit.auditdatetime between (timezone('utc',now())) - interval '1"+ rec_d_type + "' * ($2)" + sql2 = " and pgifx_sync_audit.producer_err <> 'Reconsiler1' and pgifx_sync_audit.auditdatetime between (timezone('utc',now())) - interval '1"+ rec_d_type + "' * ($2)" sql3 = " and (timezone('utc',now())) - interval '1"+ rec_d_type + "' * ($3)" sql = sql1 + sql2 + sql3 await pgClient.query(sql,paramvalues, async (err,result) => {