Hasura V2 upgrade.

This commit is contained in:
Patrick Fic
2022-09-15 14:27:59 -07:00
parent fd3a815dfa
commit 19ee43eb79
307 changed files with 1049 additions and 1 deletions

View File

@@ -1,2 +1,7 @@
version: 2
endpoint: https://rps.bodyshop.app
admin_secret: ImEXRPSDataBase
admin_secret: ImEXRPSDataBase
metadata_directory: metadata
actions:
kind: synchronous
handler_webhook_baseurl: http://localhost:3000

View File

View File

@@ -0,0 +1,6 @@
actions: []
custom_types:
enums: []
input_objects: []
objects: []
scalars: []

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,3 @@
- function:
name: search_jobs
schema: public

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1 @@
[]

365
hasura/metadata/tables.yaml Normal file
View File

@@ -0,0 +1,365 @@
- table:
name: associations
schema: public
object_relationships:
- name: bodyshop
using:
foreign_key_constraint_on: bodyshopid
- name: user
using:
foreign_key_constraint_on: email
select_permissions:
- role: user
permission:
columns:
- bodyshopid
- email
- id
filter:
user:
authid:
_eq: X-Hasura-User-Id
- table:
name: bodyshops
schema: public
array_relationships:
- name: associations
using:
foreign_key_constraint_on:
column: bodyshopid
table:
name: associations
schema: public
- name: jobs
using:
foreign_key_constraint_on:
column: bodyshopid
table:
name: jobs
schema: public
select_permissions:
- role: user
permission:
columns:
- accepted_ins_co
- created_at
- groups
- id
- ppd_diff_alert
- shopname
- targets
- updated_at
filter:
associations:
user:
authid:
_eq: X-Hasura-User-Id
update_permissions:
- role: user
permission:
columns:
- accepted_ins_co
- groups
- ppd_diff_alert
- shopname
- targets
filter:
associations:
user:
authid:
_eq: X-Hasura-User-Id
check: null
- table:
name: groupings
schema: public
select_permissions:
- role: user
permission:
columns:
- id
- created_at
- updated_at
- effective_date
- end_date
- make
- group
- type
filter: {}
- table:
name: joblines
schema: public
object_relationships:
- name: job
using:
foreign_key_constraint_on: jobid
insert_permissions:
- role: user
permission:
check:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- ignore
- jobid
- line_desc
- line_ind
- line_no
- oem_partno
- part_qty
- part_type
- price_diff
- price_diff_pc
- unq_seq
- updated_at
select_permissions:
- role: user
permission:
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- ignore
- jobid
- line_desc
- line_ind
- line_no
- oem_partno
- part_qty
- part_type
- price_diff
- price_diff_pc
- unq_seq
- updated_at
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
update_permissions:
- role: user
permission:
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- ignore
- jobid
- line_desc
- line_ind
- line_no
- oem_partno
- part_qty
- part_type
- price_diff
- price_diff_pc
- unq_seq
- updated_at
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
check: null
delete_permissions:
- role: user
permission:
backend_only: false
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
- table:
name: jobs
schema: public
object_relationships:
- name: bodyshop
using:
foreign_key_constraint_on: bodyshopid
array_relationships:
- name: joblines
using:
foreign_key_constraint_on:
column: jobid
table:
name: joblines
schema: public
insert_permissions:
- role: user
permission:
check:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- bodyshopid
- clm_no
- clm_total
- close_date
- created_at
- group
- group_verified
- id
- ins_co_nm
- loss_date
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
select_permissions:
- role: user
permission:
columns:
- bodyshopid
- clm_no
- clm_total
- close_date
- created_at
- group
- group_verified
- id
- ins_co_nm
- loss_date
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
allow_aggregations: true
update_permissions:
- role: user
permission:
columns:
- bodyshopid
- clm_no
- clm_total
- close_date
- created_at
- group
- group_verified
- id
- ins_co_nm
- loss_date
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
check: null
delete_permissions:
- role: user
permission:
backend_only: false
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
- table:
name: users
schema: public
array_relationships:
- name: associations
using:
foreign_key_constraint_on:
column: email
table:
name: associations
schema: public
insert_permissions:
- role: user
permission:
check: {}
columns:
- email
- authid
- created_at
- updated_at
select_permissions:
- role: user
permission:
columns:
- authid
- created_at
- email
- id
- updated_at
filter:
authid:
_eq: X-Hasura-User-Id
update_permissions:
- role: user
permission:
columns:
- authid
filter:
authid:
_eq: X-Hasura-User-Id
check: null
- table:
name: veh_groups
schema: public
select_permissions:
- role: user
permission:
columns:
- id
- created_at
- updated_at
- make
- type
- group
filter: {}

View File

@@ -0,0 +1 @@
version: 2

View File

@@ -0,0 +1,2 @@
DROP TABLE "public"."users";

View File

@@ -0,0 +1,18 @@
CREATE TABLE "public"."users"("email" text NOT NULL, "authid" text NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("email") );
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_users_updated_at"
BEFORE UPDATE ON "public"."users"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_users_updated_at" ON "public"."users"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@@ -0,0 +1,2 @@
DROP TABLE "public"."bodyshops";

View File

@@ -0,0 +1,19 @@
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE "public"."bodyshops"("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "shopname" text NOT NULL, PRIMARY KEY ("id") );
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_bodyshops_updated_at"
BEFORE UPDATE ON "public"."bodyshops"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_bodyshops_updated_at" ON "public"."bodyshops"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@@ -0,0 +1,2 @@
DROP TABLE "public"."associations";

View File

@@ -0,0 +1,2 @@
CREATE TABLE "public"."associations"("email" text NOT NULL, "bodyshopid" uuid NOT NULL, PRIMARY KEY ("email","bodyshopid") , FOREIGN KEY ("bodyshopid") REFERENCES "public"."bodyshops"("id") ON UPDATE cascade ON DELETE cascade, FOREIGN KEY ("email") REFERENCES "public"."users"("email") ON UPDATE cascade ON DELETE cascade);

View File

@@ -0,0 +1,2 @@
DROP TABLE "public"."jobs";

View File

@@ -0,0 +1,19 @@
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE "public"."jobs"("id" uuid NOT NULL DEFAULT gen_random_uuid(), "bodyshopid" uuid NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "ro_number" text, "ins_co_nm" text, "clm_no" text, "clm_total" numeric, "ownr_ln" text, "ownr_fn" text, "v_vin" text, "v_make_desc" text, "v_model_desc" text, "v_model_yr" text, "v_type" text, PRIMARY KEY ("id") , FOREIGN KEY ("bodyshopid") REFERENCES "public"."bodyshops"("id") ON UPDATE cascade ON DELETE cascade);
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_jobs_updated_at"
BEFORE UPDATE ON "public"."jobs"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_jobs_updated_at" ON "public"."jobs"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@@ -0,0 +1,2 @@
DROP TABLE "public"."joblines";

View File

@@ -0,0 +1,19 @@
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE "public"."joblines"("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "jobid" uuid NOT NULL, "unq_seq" text, "line_ind" text, "line_desc" text, "part_type" text, "oem_partno" text, "db_price" numeric, "act_price" numeric, "part_qty" numeric, PRIMARY KEY ("id") , FOREIGN KEY ("jobid") REFERENCES "public"."jobs"("id") ON UPDATE cascade ON DELETE cascade);
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_joblines_updated_at"
BEFORE UPDATE ON "public"."joblines"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_joblines_updated_at" ON "public"."joblines"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" drop constraint "jobs_clm_no_bodyshopid_key";

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add constraint "jobs_clm_no_bodyshopid_key" unique ("clm_no", "bodyshopid");

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" rename column "v_model" to "v_model_desc";

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" rename column "v_model_desc" to "v_model";

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" rename column "v_makedesc" to "v_make_desc";

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" rename column "v_make_desc" to "v_makedesc";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."joblines" DROP COLUMN "db_ref";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."joblines" ADD COLUMN "db_ref" text NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."joblines" DROP COLUMN "line_no";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."joblines" ADD COLUMN "line_no" numeric NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" DROP COLUMN "group";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" ADD COLUMN "group" text NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" DROP COLUMN "v_mileage";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" ADD COLUMN "v_mileage" numeric NULL;

View File

@@ -0,0 +1,2 @@
DROP TABLE "public"."veh_groups";

View File

@@ -0,0 +1,19 @@
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE "public"."veh_groups"("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "make" text NOT NULL, "type" text NOT NULL, "group" text NOT NULL, PRIMARY KEY ("id") );
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_veh_groups_updated_at"
BEFORE UPDATE ON "public"."veh_groups"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_veh_groups_updated_at" ON "public"."veh_groups"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."veh_groups" ALTER COLUMN "type" SET NOT NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."veh_groups" ALTER COLUMN "type" DROP NOT NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" DROP COLUMN "v_age";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" ADD COLUMN "v_age" numeric NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" DROP COLUMN "asgn_date";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" ADD COLUMN "asgn_date" date NULL;

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" rename column "loss_date" to "asgn_date";

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" rename column "asgn_date" to "loss_date";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."joblines" DROP COLUMN "price_diff";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."joblines" ADD COLUMN "price_diff" numeric NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."joblines" DROP COLUMN "price_diff_pc";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."joblines" ADD COLUMN "price_diff_pc" numeric NULL;

View File

@@ -0,0 +1,16 @@
CREATE OR REPLACE FUNCTION public.calculate_job_line()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."price_diff" = _new."db_price" - _new."act_price";
_new."price_diff_pc" = (_new."db_price" - _new."act_price") / _new."db_price";
_new."updated_at" = NOW();
RETURN _new;
END;
$function$
;

View File

@@ -0,0 +1,20 @@
CREATE OR REPLACE FUNCTION public.calculate_job_line()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."price_diff" = _new."db_price" - _new."act_price";
if _new."db_price" > 0 then
_new."price_diff_pc" = (_new."db_price" - _new."act_price") / _new."db_price";
end if;
RETURN _new;
END;
$function$
;

View File

@@ -0,0 +1,5 @@
create trigger calculate_updated_job_line before
update
on
public.joblines for each row execute procedure calculate_job_line();

View File

@@ -0,0 +1,2 @@
DROP TABLE "public"."targets";

View File

@@ -0,0 +1,19 @@
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE "public"."targets"("id" uuid NOT NULL DEFAULT gen_random_uuid(), "updated_at" timestamptz NOT NULL DEFAULT now(), "created_at" timestamptz NOT NULL DEFAULT now(), "label" text NOT NULL, "config" jsonb NOT NULL DEFAULT jsonb_build_object(), "start_date" date NOT NULL, "end_date" date, PRIMARY KEY ("id") );
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_targets_updated_at"
BEFORE UPDATE ON "public"."targets"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_targets_updated_at" ON "public"."targets"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@@ -0,0 +1,2 @@
DROP TABLE "public"."targets";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."bodyshops" DROP COLUMN "targets";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."bodyshops" ADD COLUMN "targets" jsonb NULL DEFAULT jsonb_build_object();

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."bodyshops" DROP COLUMN "accepted_ins_co";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."bodyshops" ADD COLUMN "accepted_ins_co" jsonb NULL DEFAULT jsonb_build_array();

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" DROP COLUMN "close_date";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" ADD COLUMN "close_date" date NULL;

View File

@@ -0,0 +1,25 @@
CREATE OR REPLACE FUNCTION public.search_jobs(search text)
RETURNS SETOF jobs
LANGUAGE plpgsql
STABLE
AS $function$ BEGIN if search = '' then return query
select *
from jobs j;
else return query
SELECT *
FROM jobs j2
WHERE ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%'
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
end if;
END $function$;

View File

@@ -0,0 +1,2 @@
drop FUNCTION public.search_jobs;

View File

@@ -0,0 +1,25 @@
CREATE OR REPLACE FUNCTION public.search_jobs(search text, startDate date, endDate date)
RETURNS SETOF jobs
LANGUAGE plpgsql
STABLE
AS $function$ BEGIN if search = '' then return query
select *
from jobs j;
else return query
SELECT *
FROM jobs j2
WHERE ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%'
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
end if;
END $function$;

View File

@@ -0,0 +1,28 @@
CREATE OR REPLACE FUNCTION public.search_jobs(search text, startDate date, endDate date)
RETURNS SETOF jobs
LANGUAGE plpgsql
STABLE
AS $function$ BEGIN if search = '' then return query
select *
from jobs j;
else return query
SELECT *
FROM jobs j2
WHERE
close_date between startDate and endDate and
(
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%')
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
end if;
END $function$;

View File

@@ -0,0 +1,52 @@
CREATE OR REPLACE FUNCTION public.search_jobs(search text, startDate date, endDate date)
RETURNS SETOF jobs
LANGUAGE plpgsql
STABLE
AS $function$ BEGIN if search = '' then return query
select *
from jobs j;
else
if startDate is null || endDate is null then
return query
SELECT *
FROM jobs j2
WHERE
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%'
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
else
return query
SELECT *
FROM jobs j2
WHERE
close_date between startDate and endDate and
(
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%')
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
end if;
end if;
END $function$;

View File

@@ -0,0 +1,52 @@
CREATE OR REPLACE FUNCTION public.search_jobs(search text, startdate date, enddate date)
RETURNS SETOF jobs
LANGUAGE plpgsql
STABLE
AS $function$ BEGIN if search = '' then return query
select *
from jobs j;
else
if (startDate is null) || (endDate is null) then
return query
SELECT *
FROM jobs j2
WHERE
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%'
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
else
return query
SELECT *
FROM jobs j2
WHERE
close_date between startDate and endDate and
(
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%')
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
end if;
end if;
END $function$;

View File

@@ -0,0 +1,52 @@
CREATE OR REPLACE FUNCTION public.search_jobs(search text, startdate date, enddate date)
RETURNS SETOF jobs
LANGUAGE plpgsql
STABLE
AS $function$ BEGIN if search = '' then return query
select *
from jobs j;
else
if (startDate is null) or (endDate is null) then
return query
SELECT *
FROM jobs j2
WHERE
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%'
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
else
return query
SELECT *
FROM jobs j2
WHERE
close_date between startDate and endDate and
(
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%')
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
end if;
end if;
END $function$;

View File

@@ -0,0 +1,52 @@
CREATE OR REPLACE FUNCTION public.search_jobs(search text, startdate date, enddate date)
RETURNS SETOF jobs
LANGUAGE plpgsql
STABLE
AS $function$ BEGIN if search = '' then return query
select *
from jobs j;
else
if (startDate is null) or (endDate is null) then
return query
SELECT *
FROM jobs j2
WHERE
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%'
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
else
return query
SELECT *
FROM jobs j2
WHERE
close_date between startDate and endDate and close_date is not null and
(
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%')
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
end if;
end if;
END $function$;

View File

@@ -0,0 +1,53 @@
CREATE OR REPLACE FUNCTION public.search_jobs(search text, startdate date, enddate date)
RETURNS SETOF jobs
LANGUAGE plpgsql
STABLE
AS $function$
BEGIN if search = '' and ((startDate is null) or (endDate is null)) then return query
select *
from jobs j;
else
if (startDate is null) or (endDate is null) then
return query
SELECT *
FROM jobs j2
WHERE
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%'
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
else
return query
SELECT *
FROM jobs j2
WHERE
close_date between startDate and endDate and close_date is not null and
(
ownr_fn ILIKE '%' || search || '%'
or ownr_ln ILIKE '%' || search || '%'
or clm_no ILIKE '%' || search || '%')
ORDER BY
clm_no ILIKE '%' || search || '%'
OR null,
ownr_fn ILIKE '%' || search || '%'
OR NULL,
ownr_ln ILIKE '%' || search || '%'
OR NULL;
end if;
end if;
END $function$;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."joblines" DROP COLUMN "ignore";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."joblines" ADD COLUMN "ignore" boolean NOT NULL DEFAULT false;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."bodyshops" DROP COLUMN "groups";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."bodyshops" ADD COLUMN "groups" jsonb NOT NULL DEFAULT jsonb_build_array();

View File

@@ -0,0 +1,6 @@
create trigger calculate_updated_job_line_insert
before
insert
on
public.joblines for each row execute function calculate_job_line();

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."bodyshops" DROP COLUMN "ppd_diff_alert";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."bodyshops" ADD COLUMN "ppd_diff_alert" numeric NULL DEFAULT .05;

View File

@@ -0,0 +1,4 @@
alter table "public"."associations"
add constraint "associations_pkey"
primary key ( "bodyshopid", "email" );

View File

@@ -0,0 +1,2 @@
alter table "public"."associations" drop constraint "associations_pkey";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."associations" DROP COLUMN "id";

View File

@@ -0,0 +1,3 @@
CREATE EXTENSION IF NOT EXISTS pgcrypto;
ALTER TABLE "public"."associations" ADD COLUMN "id" uuid NULL UNIQUE DEFAULT gen_random_uuid();

View File

@@ -0,0 +1,2 @@
alter table "public"."associations" drop constraint "associations_pkey";

View File

@@ -0,0 +1,4 @@
alter table "public"."associations"
add constraint "associations_pkey"
primary key ( "id" );

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."users" DROP COLUMN "id";

View File

@@ -0,0 +1,3 @@
CREATE EXTENSION IF NOT EXISTS pgcrypto;
ALTER TABLE "public"."users" ADD COLUMN "id" uuid NULL UNIQUE DEFAULT gen_random_uuid();

View File

@@ -0,0 +1,2 @@
DROP TABLE "public"."groupings";

View File

@@ -0,0 +1,19 @@
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE "public"."groupings"("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "effective_date" date NOT NULL, "end_date" date, "make" text NOT NULL, "group" text NOT NULL, "type" jsonb NOT NULL DEFAULT jsonb_build_array(), PRIMARY KEY ("id") );
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_groupings_updated_at"
BEFORE UPDATE ON "public"."groupings"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_groupings_updated_at" ON "public"."groupings"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@@ -0,0 +1,2 @@
ALTER TABLE ONLY "public"."groupings" ALTER COLUMN "effective_date" DROP DEFAULT;

View File

@@ -0,0 +1,2 @@
ALTER TABLE ONLY "public"."groupings" ALTER COLUMN "effective_date" SET DEFAULT now();

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" DROP COLUMN "group_verified";

View File

@@ -0,0 +1,2 @@
ALTER TABLE "public"."jobs" ADD COLUMN "group_verified" boolean NOT NULL DEFAULT false;

Some files were not shown because too many files have changed in this diff Show More