Added framework for CSI questions & viewing. Schema changes to allow anon viewing of survey BOD-98

This commit is contained in:
Patrick Fic
2020-05-22 13:36:25 -07:00
parent d8c159cde0
commit f7cc4cffa4
64 changed files with 1345 additions and 45 deletions

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: DROP TABLE "public"."csiinvites";
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\".\"csiinvites\"(\"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, \"valid\" boolean NOT NULL
DEFAULT true, \"relateddata\" jsonb, \"bodyshopid\" uuid NOT NULL, \"validuntil\"
date, PRIMARY KEY (\"id\") , FOREIGN KEY (\"jobid\") REFERENCES \"public\".\"jobs\"(\"id\")
ON UPDATE restrict ON DELETE restrict, FOREIGN KEY (\"bodyshopid\") REFERENCES
\"public\".\"bodyshops\"(\"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_csiinvites_updated_at\"\nBEFORE
UPDATE ON \"public\".\"csiinvites\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_csiinvites_updated_at\" ON \"public\".\"csiinvites\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';"
type: run_sql
- args:
name: csiinvites
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,24 @@
- args:
relationship: csiinvites
table:
name: bodyshops
schema: public
type: drop_relationship
- args:
relationship: bodyshop
table:
name: csiinvites
schema: public
type: drop_relationship
- args:
relationship: job
table:
name: csiinvites
schema: public
type: drop_relationship
- args:
relationship: csiinvites
table:
name: jobs
schema: public
type: drop_relationship

View File

@@ -0,0 +1,40 @@
- args:
name: csiinvites
table:
name: bodyshops
schema: public
using:
foreign_key_constraint_on:
column: bodyshopid
table:
name: csiinvites
schema: public
type: create_array_relationship
- args:
name: bodyshop
table:
name: csiinvites
schema: public
using:
foreign_key_constraint_on: bodyshopid
type: create_object_relationship
- args:
name: job
table:
name: csiinvites
schema: public
using:
foreign_key_constraint_on: jobid
type: create_object_relationship
- args:
name: csiinvites
table:
name: jobs
schema: public
using:
foreign_key_constraint_on:
column: jobid
table:
name: csiinvites
schema: public
type: create_array_relationship

View File

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

View File

@@ -0,0 +1,30 @@
- args:
permission:
allow_upsert: true
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- jobid
- valid
- relateddata
- bodyshopid
- validuntil
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csiinvites
schema: public
type: create_insert_permission

View File

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

View File

@@ -0,0 +1,28 @@
- args:
permission:
allow_aggregations: false
columns:
- valid
- validuntil
- relateddata
- created_at
- updated_at
- bodyshopid
- id
- jobid
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: csiinvites
schema: public
type: create_select_permission

View File

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

View File

@@ -0,0 +1,29 @@
- args:
permission:
columns:
- valid
- validuntil
- relateddata
- created_at
- updated_at
- bodyshopid
- id
- jobid
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csiinvites
schema: public
type: create_update_permission

View File

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

View File

@@ -0,0 +1,16 @@
- args:
permission:
allow_aggregations: false
columns:
- id
- relateddata
- valid
- validuntil
computed_fields: []
filter: {}
limit: 1
role: anonymous
table:
name: csiinvites
schema: public
type: create_select_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."csi" rename to "csiinvites";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."csiinvites" rename to "csi";
type: run_sql

View File

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

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."csi" ADD COLUMN "response" jsonb NULL;
type: run_sql

View File

@@ -0,0 +1,35 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_insert_permission
- args:
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- jobid
- valid
- relateddata
- bodyshopid
- validuntil
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csi
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_insert_permission
- args:
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- response
- updated_at
- valid
- validuntil
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csi
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,33 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- valid
- validuntil
- relateddata
- created_at
- updated_at
- bodyshopid
- id
- jobid
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: csi
schema: public
type: create_select_permission

View File

@@ -0,0 +1,34 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- response
- updated_at
- valid
- validuntil
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: csi
schema: public
type: create_select_permission

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_insert_permission
- args:
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- response
- updated_at
- valid
- validuntil
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csi
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,35 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_insert_permission
- args:
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- updated_at
- valid
- validuntil
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csi
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,22 @@
- args:
role: anonymous
table:
name: csi
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- id
- relateddata
- valid
- validuntil
computed_fields: []
filter: {}
limit: 1
role: anonymous
table:
name: csi
schema: public
type: create_select_permission

View File

@@ -0,0 +1,24 @@
- args:
role: anonymous
table:
name: csi
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- id
- relateddata
- valid
- validuntil
computed_fields: []
filter:
valid:
_eq: true
limit: 1
role: anonymous
table:
name: csi
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: anonymous
table:
name: csi
schema: public
type: drop_update_permission

View File

@@ -0,0 +1,17 @@
- args:
permission:
columns:
- response
- updated_at
filter:
valid:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: anonymous
table:
name: csi
schema: public
type: create_update_permission

View File

@@ -0,0 +1,23 @@
- args:
role: anonymous
table:
name: csi
schema: public
type: drop_update_permission
- args:
permission:
columns:
- response
- updated_at
filter:
valid:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: anonymous
table:
name: csi
schema: public
type: create_update_permission

View File

@@ -0,0 +1,22 @@
- args:
role: anonymous
table:
name: csi
schema: public
type: drop_update_permission
- args:
permission:
columns:
- response
filter:
valid:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: anonymous
table:
name: csi
schema: public
type: create_update_permission

View File

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

View File

@@ -0,0 +1,25 @@
- 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\".\"csiquestion\"(\"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, \"current\" boolean NOT
NULL DEFAULT true, \"config\" jsonb, PRIMARY KEY (\"id\") , FOREIGN KEY (\"bodyshopid\")
REFERENCES \"public\".\"bodyshops\"(\"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_csiquestion_updated_at\"\nBEFORE
UPDATE ON \"public\".\"csiquestion\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_csiquestion_updated_at\" ON \"public\".\"csiquestion\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';"
type: run_sql
- args:
name: csiquestion
schema: public
type: add_existing_table_or_view

View File

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

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."csi" ADD COLUMN "questionset" uuid NULL;
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."csiquestions" rename to "csiquestion";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."csiquestion" rename to "csiquestions";
type: run_sql

View File

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

View File

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

View File

@@ -0,0 +1,24 @@
- args:
relationship: csiquestions
table:
name: bodyshops
schema: public
type: drop_relationship
- args:
relationship: csiquestion
table:
name: csi
schema: public
type: drop_relationship
- args:
relationship: bodyshop
table:
name: csiquestions
schema: public
type: drop_relationship
- args:
relationship: csis
table:
name: csiquestions
schema: public
type: drop_relationship

View File

@@ -0,0 +1,40 @@
- args:
name: csiquestions
table:
name: bodyshops
schema: public
using:
foreign_key_constraint_on:
column: bodyshopid
table:
name: csiquestions
schema: public
type: create_array_relationship
- args:
name: csiquestion
table:
name: csi
schema: public
using:
foreign_key_constraint_on: questionset
type: create_object_relationship
- args:
name: bodyshop
table:
name: csiquestions
schema: public
using:
foreign_key_constraint_on: bodyshopid
type: create_object_relationship
- args:
name: csis
table:
name: csiquestions
schema: public
using:
foreign_key_constraint_on:
column: questionset
table:
name: csi
schema: public
type: create_array_relationship

View File

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

View File

@@ -0,0 +1,14 @@
- args:
permission:
allow_aggregations: false
columns:
- config
- id
computed_fields: []
filter: {}
limit: 1
role: anonymous
table:
name: csiquestions
schema: public
type: create_select_permission

View File

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

View File

@@ -0,0 +1,28 @@
- args:
permission:
allow_upsert: true
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- current
- config
- created_at
- updated_at
- bodyshopid
- id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csiquestions
schema: public
type: create_insert_permission

View File

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

View File

@@ -0,0 +1,26 @@
- args:
permission:
allow_aggregations: false
columns:
- current
- config
- created_at
- updated_at
- bodyshopid
- id
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: csiquestions
schema: public
type: create_select_permission

View File

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

View File

@@ -0,0 +1,22 @@
- args:
permission:
columns:
- current
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csiquestions
schema: public
type: create_update_permission

View File

@@ -384,6 +384,20 @@ tables:
table:
schema: public
name: courtesycars
- name: csiinvites
using:
foreign_key_constraint_on:
column: bodyshopid
table:
schema: public
name: csi
- name: csiquestions
using:
foreign_key_constraint_on:
column: bodyshopid
table:
schema: public
name: csiquestions
- name: employees
using:
foreign_key_constraint_on:
@@ -869,6 +883,175 @@ tables:
_eq: X-Hasura-User-Id
- active:
_eq: true
- table:
schema: public
name: csi
object_relationships:
- name: bodyshop
using:
foreign_key_constraint_on: bodyshopid
- name: csiquestion
using:
foreign_key_constraint_on: questionset
- name: job
using:
foreign_key_constraint_on: jobid
insert_permissions:
- role: user
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- updated_at
- valid
- validuntil
select_permissions:
- role: anonymous
permission:
columns:
- id
- relateddata
- valid
- validuntil
filter:
valid:
_eq: true
limit: 1
- role: user
permission:
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- response
- updated_at
- valid
- validuntil
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
update_permissions:
- role: anonymous
permission:
columns:
- response
filter:
valid:
_eq: true
- role: user
permission:
columns:
- valid
- validuntil
- relateddata
- created_at
- updated_at
- bodyshopid
- id
- jobid
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- table:
schema: public
name: csiquestions
object_relationships:
- name: bodyshop
using:
foreign_key_constraint_on: bodyshopid
array_relationships:
- name: csis
using:
foreign_key_constraint_on:
column: questionset
table:
schema: public
name: csi
insert_permissions:
- role: user
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- current
- config
- created_at
- updated_at
- bodyshopid
- id
select_permissions:
- role: anonymous
permission:
columns:
- config
- id
filter: {}
limit: 1
- role: user
permission:
columns:
- current
- config
- created_at
- updated_at
- bodyshopid
- id
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
update_permissions:
- role: user
permission:
columns:
- current
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- table:
schema: public
name: documents
@@ -1624,6 +1807,13 @@ tables:
table:
schema: public
name: cccontracts
- name: csiinvites
using:
foreign_key_constraint_on:
column: jobid
table:
schema: public
name: csi
- name: documents
using:
foreign_key_constraint_on: