Query 19,20,21,22 migrated - Find same case details in punching screen in case of co-applicant

This commit is contained in:
2026-08-02 14:34:21 +05:30
parent 4705649ae8
commit 60f9aa05a0
16 changed files with 233 additions and 215 deletions

View File

@@ -0,0 +1,66 @@
-- Remove view/materialized-view dependencies from the application-save workflow.
-- Each replacement expands the original view predicate against its base tables.
DO $migration$
DECLARE
change record;
definition text;
BEGIN
FOR change IN
SELECT *
FROM (VALUES
(
'public.autocut(integer,text,integer)'::regprocedure,
'FROM main_mainopr WHERE uuid = unqueid',
'FROM main m JOIN main_operations mo ON mo.uuid::text = m.uuid::text WHERE m.isdeleted = 0 AND m.uuid = unqueid'
),
(
'public.autocut(integer,text,integer)'::regprocedure,
'SELECT rv,ov,pv,rcolony,ocolony,pcolony,company_id,branch_id,oprsendon,allocationon,earlier,negative',
'SELECT m.rv,m.ov,m.pv,m.rcolony,m.ocolony,m.pcolony,m.company_id,m.branch_id,mo.oprsendon,mo.allocationon,mo.earlier,mo.negative'
),
(
'public.dedupebyuuid(text,integer,text,text,integer)'::regprocedure,
'from cutoff_operations where uuid=uniqueid',
'from (select c.*, mo.cutoffon from main c join main_operations mo on mo.uuid::text = c.uuid::text join portfolio p on p.portfolio_id = c.portfolio_id join company co on co.company_id = c.company_id where c.isdeleted = 0 and mo.sdone = 0) source_case where uuid=uniqueid'
),
(
'public.smsentry(text,integer,text,integer,integer,integer,integer)'::regprocedure,
'from cutoff_operations where uuid=uniqueid',
'from (select c.*, p.portname from main c join main_operations mo on mo.uuid::text = c.uuid::text join portfolio p on p.portfolio_id = c.portfolio_id join company co on co.company_id = c.company_id where c.isdeleted = 0 and mo.sdone = 0) source_case where uuid=uniqueid'
),
(
'public.checkaddress(text,text,integer,text,integer,text,date,integer,timestamp without time zone,integer)'::regprocedure,
'from mview_main_mainopr where',
'from (select m.*, mo.cutoffon from main m join main_operations mo on mo.uuid::text = m.uuid::text where m.isdeleted = 0 and m.receivedate > (current_date - interval ''6 months'')) prior_cases where'
),
(
'public.checkphonenos(text,text,text,integer,text,date,timestamp without time zone,integer)'::regprocedure,
'from mview_main_mainopr where',
'from (select m.*, mo.cutoffon from main m join main_operations mo on mo.uuid::text = m.uuid::text where m.isdeleted = 0 and m.receivedate > (current_date - interval ''6 months'')) prior_cases where'
),
(
'public.checknamedob(text,text,integer,text,date)'::regprocedure,
'from mview_main_namedob_ear where',
'from (select m.* from main m where m.dob::text <> '''' and m.dob is not null and m.isdeleted = 0 and m.receivedate > (current_date - interval ''6 months'')) prior_namedob_cases where'
),
(
'public.sendtooperation(character,integer,character,integer,integer,integer,integer)'::regprocedure,
'from main_mainopr m where',
'from (select mn.*, mo.batch, mo.rvdone, mo.rvdoneon, mo.rvdoneby, mo.ovdone, mo.ovdoneon, mo.ovdoneby, mo.tvrdone, mo.tvrdoneon, mo.tvrdoneby, mo.pvdone, mo.pvdoneon, mo.pvdoneby, mo.docdone, mo.docdoneon, mo.docdoneby from main mn join main_operations mo on mo.uuid::text = mn.uuid::text where mn.isdeleted = 0) m where'
)
) AS replacements(function_oid, old_sql, new_sql)
LOOP
definition := pg_get_functiondef(change.function_oid);
-- Makes the migration safe to re-run after a successful deployment.
IF position(change.old_sql IN definition) = 0 THEN
IF position(change.new_sql IN definition) = 0 THEN
RAISE EXCEPTION 'Expected SQL was not found in %', change.function_oid;
END IF;
CONTINUE;
END IF;
EXECUTE replace(definition, change.old_sql, change.new_sql);
END LOOP;
END
$migration$;