From 614549a5452f561c6f8c9d4e9b1442e0034841b5 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 12 Apr 2023 13:08:39 -0700 Subject: [PATCH] Include employee team changes from Payroll Based Changes. --- hasura/metadata/tables.yaml | 22 +++++++++---------- .../down.sql | 1 + .../up.sql | 18 +++++++++++++++ .../down.sql | 1 + .../up.sql | 18 +++++++++++++++ 5 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql create mode 100644 hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql create mode 100644 hasura/migrations/1681156265693_create_table_public_employee_team_members/down.sql create mode 100644 hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 6fe62169b..0055e4b7a 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -2391,32 +2391,30 @@ - active: _eq: true columns: - - billid - - bodyshopid - - created_at - id + - created_at + - updated_at - jobid - - message - - metadata + - billid - paymentid - successful - - updated_at + - message + - bodyshopid - useremail select_permissions: - role: user permission: columns: + - successful + - message + - useremail + - created_at + - updated_at - billid - bodyshopid - - created_at - id - jobid - - message - - metadata - paymentid - - successful - - updated_at - - useremail filter: bodyshop: associations: diff --git a/hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql b/hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql new file mode 100644 index 000000000..1639caf73 --- /dev/null +++ b/hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."employee_teams"; diff --git a/hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql b/hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql new file mode 100644 index 000000000..994e15280 --- /dev/null +++ b/hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql @@ -0,0 +1,18 @@ +CREATE TABLE "public"."employee_teams" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "bodyshopid" uuid NOT NULL, "name" text NOT NULL, "active" boolean NOT NULL DEFAULT true, 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_employee_teams_updated_at" +BEFORE UPDATE ON "public"."employee_teams" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_employee_teams_updated_at" ON "public"."employee_teams" +IS 'trigger to set value of column "updated_at" to current timestamp on row update'; +CREATE EXTENSION IF NOT EXISTS pgcrypto; diff --git a/hasura/migrations/1681156265693_create_table_public_employee_team_members/down.sql b/hasura/migrations/1681156265693_create_table_public_employee_team_members/down.sql new file mode 100644 index 000000000..14ab424ce --- /dev/null +++ b/hasura/migrations/1681156265693_create_table_public_employee_team_members/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."employee_team_members"; diff --git a/hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql b/hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql new file mode 100644 index 000000000..e6a32938f --- /dev/null +++ b/hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql @@ -0,0 +1,18 @@ +CREATE TABLE "public"."employee_team_members" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "teamid" uuid NOT NULL, "employeeid" uuid NOT NULL, "labor_rates" jsonb NOT NULL DEFAULT jsonb_build_object(), "percentage" numeric NOT NULL DEFAULT 0, PRIMARY KEY ("id") , FOREIGN KEY ("teamid") REFERENCES "public"."employee_teams"("id") ON UPDATE cascade ON DELETE cascade, FOREIGN KEY ("employeeid") REFERENCES "public"."employees"("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_employee_team_members_updated_at" +BEFORE UPDATE ON "public"."employee_team_members" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_employee_team_members_updated_at" ON "public"."employee_team_members" +IS 'trigger to set value of column "updated_at" to current timestamp on row update'; +CREATE EXTENSION IF NOT EXISTS pgcrypto;