IO-710 Export Log Setup. [ci skip]

This commit is contained in:
Patrick Fic
2021-04-21 12:08:32 -07:00
parent 5f9e813940
commit 6d9576b9a4
26 changed files with 780 additions and 8 deletions

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: DROP TABLE "public"."exportlog";
type: run_sql

View File

@@ -0,0 +1,27 @@
- args:
cascade: false
read_only: false
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
cascade: false
read_only: false
sql: "CREATE TABLE \"public\".\"exportlog\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"jobid\" uuid, \"billid\" uuid, \"paymentid\" uuid,
\"successful\" boolean NOT NULL DEFAULT false, \"message\" text NOT NULL, \"bodyshopid\"
uuid NOT NULL, PRIMARY KEY (\"id\") , FOREIGN KEY (\"jobid\") REFERENCES \"public\".\"jobs\"(\"id\")
ON UPDATE restrict ON DELETE restrict, FOREIGN KEY (\"paymentid\") REFERENCES
\"public\".\"payments\"(\"id\") ON UPDATE restrict ON DELETE restrict, FOREIGN
KEY (\"billid\") REFERENCES \"public\".\"bills\"(\"id\") ON UPDATE restrict
ON DELETE restrict);\nCREATE OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS
TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\"
= NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_exportlog_updated_at\"\nBEFORE
UPDATE ON \"public\".\"exportlog\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_exportlog_updated_at\" ON \"public\".\"exportlog\" \nIS
'trigger to set value of column \"updated_at\" to current timestamp on row update';"
type: run_sql
- args:
name: exportlog
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."exportlog" DROP COLUMN "useremail";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."exportlog" ADD COLUMN "useremail" text NOT NULL;
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."exportlog" drop constraint "exportlog_useremail_fkey";
type: run_sql

View File

@@ -0,0 +1,10 @@
- args:
cascade: false
read_only: false
sql: |-
alter table "public"."exportlog"
add constraint "exportlog_useremail_fkey"
foreign key ("useremail")
references "public"."users"
("email") on update restrict on delete restrict;
type: run_sql

View File

@@ -0,0 +1,48 @@
- args:
relationship: exportlogs
table:
name: users
schema: public
type: drop_relationship
- args:
relationship: exportlogs
table:
name: jobs
schema: public
type: drop_relationship
- args:
relationship: exportlogs
table:
name: bills
schema: public
type: drop_relationship
- args:
relationship: exportlogs
table:
name: payments
schema: public
type: drop_relationship
- args:
relationship: payment
table:
name: exportlog
schema: public
type: drop_relationship
- args:
relationship: user
table:
name: exportlog
schema: public
type: drop_relationship
- args:
relationship: job
table:
name: exportlog
schema: public
type: drop_relationship
- args:
relationship: bill
table:
name: exportlog
schema: public
type: drop_relationship

View File

@@ -0,0 +1,80 @@
- args:
name: exportlogs
table:
name: users
schema: public
using:
foreign_key_constraint_on:
column: useremail
table:
name: exportlog
schema: public
type: create_array_relationship
- args:
name: exportlogs
table:
name: jobs
schema: public
using:
foreign_key_constraint_on:
column: jobid
table:
name: exportlog
schema: public
type: create_array_relationship
- args:
name: exportlogs
table:
name: bills
schema: public
using:
foreign_key_constraint_on:
column: billid
table:
name: exportlog
schema: public
type: create_array_relationship
- args:
name: exportlogs
table:
name: payments
schema: public
using:
foreign_key_constraint_on:
column: paymentid
table:
name: exportlog
schema: public
type: create_array_relationship
- args:
name: payment
table:
name: exportlog
schema: public
using:
foreign_key_constraint_on: paymentid
type: create_object_relationship
- args:
name: user
table:
name: exportlog
schema: public
using:
foreign_key_constraint_on: useremail
type: create_object_relationship
- args:
name: job
table:
name: exportlog
schema: public
using:
foreign_key_constraint_on: jobid
type: create_object_relationship
- args:
name: bill
table:
name: exportlog
schema: public
using:
foreign_key_constraint_on: billid
type: create_object_relationship

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."exportlog" drop constraint "exportlog_bodyshopid_fkey";
type: run_sql

View File

@@ -0,0 +1,10 @@
- args:
cascade: false
read_only: false
sql: |-
alter table "public"."exportlog"
add constraint "exportlog_bodyshopid_fkey"
foreign key ("bodyshopid")
references "public"."bodyshops"
("id") on update restrict on delete restrict;
type: run_sql

View File

@@ -0,0 +1,12 @@
- args:
relationship: exportlogs
table:
name: bodyshops
schema: public
type: drop_relationship
- args:
relationship: bodyshop
table:
name: exportlog
schema: public
type: drop_relationship

View File

@@ -0,0 +1,20 @@
- args:
name: exportlogs
table:
name: bodyshops
schema: public
using:
foreign_key_constraint_on:
column: bodyshopid
table:
name: exportlog
schema: public
type: create_array_relationship
- args:
name: bodyshop
table:
name: exportlog
schema: public
using:
foreign_key_constraint_on: bodyshopid
type: create_object_relationship

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: exportlog
schema: public
type: drop_insert_permission

View File

@@ -0,0 +1,30 @@
- args:
permission:
allow_upsert: true
backend_only: false
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- jobid
- billid
- paymentid
- successful
- message
- bodyshopid
- useremail
set: {}
role: user
table:
name: exportlog
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: exportlog
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,31 @@
- args:
permission:
allow_aggregations: true
backend_only: false
columns:
- successful
- message
- useremail
- created_at
- updated_at
- billid
- bodyshopid
- id
- jobid
- paymentid
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: exportlog
schema: public
type: create_select_permission

View File

@@ -495,6 +495,13 @@ tables:
table:
schema: public
name: documents
- name: exportlogs
using:
foreign_key_constraint_on:
column: billid
table:
schema: public
name: exportlog
- name: parts_orders
using:
foreign_key_constraint_on:
@@ -691,6 +698,13 @@ tables:
table:
schema: public
name: employees
- name: exportlogs
using:
foreign_key_constraint_on:
column: bodyshopid
table:
schema: public
name: exportlog
- name: jobs
using:
foreign_key_constraint_on:
@@ -1733,6 +1747,73 @@ tables:
_eq: X-Hasura-User-Id
- active:
_eq: true
- table:
schema: public
name: exportlog
object_relationships:
- name: bill
using:
foreign_key_constraint_on: billid
- name: bodyshop
using:
foreign_key_constraint_on: bodyshopid
- name: job
using:
foreign_key_constraint_on: jobid
- name: payment
using:
foreign_key_constraint_on: paymentid
- name: user
using:
foreign_key_constraint_on: useremail
insert_permissions:
- role: user
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- jobid
- billid
- paymentid
- successful
- message
- bodyshopid
- useremail
backend_only: false
select_permissions:
- role: user
permission:
columns:
- successful
- message
- useremail
- created_at
- updated_at
- billid
- bodyshopid
- id
- jobid
- paymentid
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
allow_aggregations: true
- table:
schema: public
name: job_conversations
@@ -2167,6 +2248,13 @@ tables:
table:
schema: public
name: documents
- name: exportlogs
using:
foreign_key_constraint_on:
column: jobid
table:
schema: public
name: exportlog
- name: job_conversations
using:
foreign_key_constraint_on:
@@ -3582,6 +3670,14 @@ tables:
- name: job
using:
foreign_key_constraint_on: jobid
array_relationships:
- name: exportlogs
using:
foreign_key_constraint_on:
column: paymentid
table:
schema: public
name: exportlog
insert_permissions:
- role: user
permission:
@@ -3895,6 +3991,13 @@ tables:
table:
schema: public
name: audit_trail
- name: exportlogs
using:
foreign_key_constraint_on:
column: useremail
table:
schema: public
name: exportlog
- name: messages
using:
foreign_key_constraint_on: