BOD-14 Schema Changes for messaging

This commit is contained in:
Patrick Fic
2020-03-25 09:35:02 -07:00
parent 1409ef058c
commit 5b5ffe21cd
34 changed files with 552 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,24 @@
- 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\".\"conversations\"(\"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, \"phone_num\" text NOT
NULL, 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_conversations_updated_at\"\nBEFORE
UPDATE ON \"public\".\"conversations\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_conversations_updated_at\" ON \"public\".\"conversations\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';"
type: run_sql
- args:
name: conversations
schema: public
type: add_existing_table_or_view

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,27 @@
- 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
- bodyshopid
- phone_num
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: conversations
schema: public
type: create_insert_permission

View File

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

View File

@@ -0,0 +1,25 @@
- args:
permission:
allow_aggregations: false
columns:
- phone_num
- 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: conversations
schema: public
type: create_select_permission

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,26 @@
- 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\".\"messages\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"msid\" text NOT NULL, \"conversationid\" uuid NOT
NULL, \"text\" text, \"image\" boolean NOT NULL DEFAULT false, \"image_path\"
text, \"sent\" boolean NOT NULL DEFAULT false, \"delivered\" boolean NOT NULL
DEFAULT false, PRIMARY KEY (\"id\") , FOREIGN KEY (\"conversationid\") REFERENCES
\"public\".\"conversations\"(\"id\") ON UPDATE restrict ON DELETE restrict,
UNIQUE (\"msid\"));\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_messages_updated_at\"\nBEFORE
UPDATE ON \"public\".\"messages\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_messages_updated_at\" ON \"public\".\"messages\" \nIS
'trigger to set value of column \"updated_at\" to current timestamp on row update';"
type: run_sql
- args:
name: messages
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,12 @@
- args:
relationship: messages
table:
name: conversations
schema: public
type: drop_relationship
- args:
relationship: conversation
table:
name: messages
schema: public
type: drop_relationship

View File

@@ -0,0 +1,20 @@
- args:
name: messages
table:
name: conversations
schema: public
using:
foreign_key_constraint_on:
column: conversationid
table:
name: messages
schema: public
type: create_array_relationship
- args:
name: conversation
table:
name: messages
schema: public
using:
foreign_key_constraint_on: conversationid
type: create_object_relationship

View File

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

View File

@@ -0,0 +1,33 @@
- args:
permission:
allow_upsert: true
check:
conversation:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- msid
- conversationid
- text
- image
- image_path
- sent
- delivered
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: messages
schema: public
type: create_insert_permission

View File

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

View File

@@ -0,0 +1,31 @@
- args:
permission:
allow_aggregations: false
columns:
- delivered
- image
- sent
- image_path
- msid
- text
- created_at
- updated_at
- conversationid
- id
computed_fields: []
filter:
conversation:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: messages
schema: public
type: create_select_permission

View File

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

View File

@@ -0,0 +1,32 @@
- args:
permission:
columns:
- delivered
- image
- sent
- image_path
- msid
- text
- created_at
- updated_at
- conversationid
- id
filter:
conversation:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: messages
schema: public
type: create_update_permission

View File

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

View File

@@ -0,0 +1,17 @@
- args:
permission:
filter:
conversation:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: messages
schema: public
type: create_delete_permission

View File

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

View File

@@ -0,0 +1,13 @@
- args:
cascade: false
read_only: false
sql: CREATE TABLE "public"."job_conversations"("jobid" uuid NOT NULL, "conversationid"
uuid NOT NULL, PRIMARY KEY ("jobid","conversationid") , FOREIGN KEY ("jobid")
REFERENCES "public"."jobs"("id") ON UPDATE restrict ON DELETE restrict, FOREIGN
KEY ("conversationid") REFERENCES "public"."conversations"("id") ON UPDATE restrict
ON DELETE restrict);
type: run_sql
- args:
name: job_conversations
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,24 @@
- args:
relationship: job_conversations
table:
name: conversations
schema: public
type: drop_relationship
- args:
relationship: job
table:
name: job_conversations
schema: public
type: drop_relationship
- args:
relationship: conversation
table:
name: job_conversations
schema: public
type: drop_relationship
- args:
relationship: job_conversations
table:
name: jobs
schema: public
type: drop_relationship

View File

@@ -0,0 +1,40 @@
- args:
name: job_conversations
table:
name: conversations
schema: public
using:
foreign_key_constraint_on:
column: conversationid
table:
name: job_conversations
schema: public
type: create_array_relationship
- args:
name: job
table:
name: job_conversations
schema: public
using:
foreign_key_constraint_on: jobid
type: create_object_relationship
- args:
name: conversation
table:
name: job_conversations
schema: public
using:
foreign_key_constraint_on: conversationid
type: create_object_relationship
- args:
name: job_conversations
table:
name: jobs
schema: public
using:
foreign_key_constraint_on:
column: jobid
table:
name: job_conversations
schema: public
type: create_array_relationship

View File

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

View File

@@ -0,0 +1,25 @@
- args:
permission:
allow_upsert: true
check:
conversation:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- jobid
- conversationid
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: job_conversations
schema: public
type: create_insert_permission

View File

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

View File

@@ -0,0 +1,23 @@
- args:
permission:
allow_aggregations: false
columns:
- conversationid
- jobid
computed_fields: []
filter:
conversation:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: job_conversations
schema: public
type: create_select_permission

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,17 @@
- args:
permission:
filter:
conversation:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: job_conversations
schema: public
type: create_delete_permission