Further index changes.
This commit is contained in:
34
hasura/migrations/1726871384601_run_sql_migration/down.sql
Normal file
34
hasura/migrations/1726871384601_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- CREATE OR REPLACE FUNCTION public.search_exportlog(search text)
|
||||
-- RETURNS SETOF exportlog
|
||||
-- LANGUAGE plpgsql
|
||||
-- STABLE
|
||||
-- AS $function$ BEGIN IF search = '' THEN RETURN query
|
||||
-- SELECT
|
||||
-- *
|
||||
-- FROM
|
||||
-- exportlog e;
|
||||
-- ELSE RETURN query
|
||||
-- SELECT
|
||||
-- e.*
|
||||
-- FROM
|
||||
-- exportlog e
|
||||
-- LEFT JOIN jobs j on j.id = e.jobid
|
||||
-- LEFT JOIN payments p
|
||||
-- ON p.id = e.paymentid
|
||||
-- LEFT JOIN bills b
|
||||
-- ON e.billid = b.id
|
||||
-- WHERE
|
||||
-- (
|
||||
-- j.ro_number ILIKE '%' || search
|
||||
-- OR b.invoice_number ILIKE '%' || search
|
||||
-- OR p.paymentnum ILIKE '%' || search
|
||||
-- OR e.useremail ILIKE '%' || search
|
||||
-- )
|
||||
-- AND (e.jobid = j.id
|
||||
-- or e.paymentid = p.id
|
||||
-- or e.billid = b.id)
|
||||
-- ;
|
||||
-- END IF;
|
||||
-- END $function$;
|
||||
32
hasura/migrations/1726871384601_run_sql_migration/up.sql
Normal file
32
hasura/migrations/1726871384601_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
CREATE OR REPLACE FUNCTION public.search_exportlog(search text)
|
||||
RETURNS SETOF exportlog
|
||||
LANGUAGE plpgsql
|
||||
STABLE
|
||||
AS $function$ BEGIN IF search = '' THEN RETURN query
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
exportlog e;
|
||||
ELSE RETURN query
|
||||
SELECT
|
||||
e.*
|
||||
FROM
|
||||
exportlog e
|
||||
LEFT JOIN jobs j on j.id = e.jobid
|
||||
LEFT JOIN payments p
|
||||
ON p.id = e.paymentid
|
||||
LEFT JOIN bills b
|
||||
ON e.billid = b.id
|
||||
WHERE
|
||||
(
|
||||
j.ro_number ILIKE '%' || search
|
||||
OR b.invoice_number ILIKE '%' || search
|
||||
OR p.paymentnum ILIKE '%' || search
|
||||
OR e.useremail ILIKE '%' || search
|
||||
)
|
||||
AND (e.jobid = j.id
|
||||
or e.paymentid = p.id
|
||||
or e.billid = b.id)
|
||||
;
|
||||
END IF;
|
||||
END $function$;
|
||||
Reference in New Issue
Block a user