diff --git a/hasura/migrations/1585153417017_create_table_public_conversations/down.yaml b/hasura/migrations/1585153417017_create_table_public_conversations/down.yaml new file mode 100644 index 000000000..7506556ae --- /dev/null +++ b/hasura/migrations/1585153417017_create_table_public_conversations/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: DROP TABLE "public"."conversations"; + type: run_sql diff --git a/hasura/migrations/1585153417017_create_table_public_conversations/up.yaml b/hasura/migrations/1585153417017_create_table_public_conversations/up.yaml new file mode 100644 index 000000000..d47a32f63 --- /dev/null +++ b/hasura/migrations/1585153417017_create_table_public_conversations/up.yaml @@ -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 diff --git a/hasura/migrations/1585153424258_track_all_relationships/down.yaml b/hasura/migrations/1585153424258_track_all_relationships/down.yaml new file mode 100644 index 000000000..743e81ec2 --- /dev/null +++ b/hasura/migrations/1585153424258_track_all_relationships/down.yaml @@ -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 diff --git a/hasura/migrations/1585153424258_track_all_relationships/up.yaml b/hasura/migrations/1585153424258_track_all_relationships/up.yaml new file mode 100644 index 000000000..11d3f3218 --- /dev/null +++ b/hasura/migrations/1585153424258_track_all_relationships/up.yaml @@ -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 diff --git a/hasura/migrations/1585153464139_update_permission_user_public_table_conversations/down.yaml b/hasura/migrations/1585153464139_update_permission_user_public_table_conversations/down.yaml new file mode 100644 index 000000000..67eac0759 --- /dev/null +++ b/hasura/migrations/1585153464139_update_permission_user_public_table_conversations/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: conversations + schema: public + type: drop_insert_permission diff --git a/hasura/migrations/1585153464139_update_permission_user_public_table_conversations/up.yaml b/hasura/migrations/1585153464139_update_permission_user_public_table_conversations/up.yaml new file mode 100644 index 000000000..099167a94 --- /dev/null +++ b/hasura/migrations/1585153464139_update_permission_user_public_table_conversations/up.yaml @@ -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 diff --git a/hasura/migrations/1585153470172_update_permission_user_public_table_conversations/down.yaml b/hasura/migrations/1585153470172_update_permission_user_public_table_conversations/down.yaml new file mode 100644 index 000000000..b20d844fd --- /dev/null +++ b/hasura/migrations/1585153470172_update_permission_user_public_table_conversations/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: conversations + schema: public + type: drop_select_permission diff --git a/hasura/migrations/1585153470172_update_permission_user_public_table_conversations/up.yaml b/hasura/migrations/1585153470172_update_permission_user_public_table_conversations/up.yaml new file mode 100644 index 000000000..a72ab0fcd --- /dev/null +++ b/hasura/migrations/1585153470172_update_permission_user_public_table_conversations/up.yaml @@ -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 diff --git a/hasura/migrations/1585153476909_update_permission_user_public_table_conversations/down.yaml b/hasura/migrations/1585153476909_update_permission_user_public_table_conversations/down.yaml new file mode 100644 index 000000000..18af93644 --- /dev/null +++ b/hasura/migrations/1585153476909_update_permission_user_public_table_conversations/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: conversations + schema: public + type: drop_update_permission diff --git a/hasura/migrations/1585153476909_update_permission_user_public_table_conversations/up.yaml b/hasura/migrations/1585153476909_update_permission_user_public_table_conversations/up.yaml new file mode 100644 index 000000000..117094ed9 --- /dev/null +++ b/hasura/migrations/1585153476909_update_permission_user_public_table_conversations/up.yaml @@ -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 diff --git a/hasura/migrations/1585153777706_create_table_public_messages/down.yaml b/hasura/migrations/1585153777706_create_table_public_messages/down.yaml new file mode 100644 index 000000000..44cc529da --- /dev/null +++ b/hasura/migrations/1585153777706_create_table_public_messages/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: DROP TABLE "public"."messages"; + type: run_sql diff --git a/hasura/migrations/1585153777706_create_table_public_messages/up.yaml b/hasura/migrations/1585153777706_create_table_public_messages/up.yaml new file mode 100644 index 000000000..90098df5e --- /dev/null +++ b/hasura/migrations/1585153777706_create_table_public_messages/up.yaml @@ -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 diff --git a/hasura/migrations/1585153792735_track_all_relationships/down.yaml b/hasura/migrations/1585153792735_track_all_relationships/down.yaml new file mode 100644 index 000000000..7cd99e818 --- /dev/null +++ b/hasura/migrations/1585153792735_track_all_relationships/down.yaml @@ -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 diff --git a/hasura/migrations/1585153792735_track_all_relationships/up.yaml b/hasura/migrations/1585153792735_track_all_relationships/up.yaml new file mode 100644 index 000000000..64e797095 --- /dev/null +++ b/hasura/migrations/1585153792735_track_all_relationships/up.yaml @@ -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 diff --git a/hasura/migrations/1585153822636_update_permission_user_public_table_messages/down.yaml b/hasura/migrations/1585153822636_update_permission_user_public_table_messages/down.yaml new file mode 100644 index 000000000..0755f37de --- /dev/null +++ b/hasura/migrations/1585153822636_update_permission_user_public_table_messages/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: messages + schema: public + type: drop_insert_permission diff --git a/hasura/migrations/1585153822636_update_permission_user_public_table_messages/up.yaml b/hasura/migrations/1585153822636_update_permission_user_public_table_messages/up.yaml new file mode 100644 index 000000000..88977313f --- /dev/null +++ b/hasura/migrations/1585153822636_update_permission_user_public_table_messages/up.yaml @@ -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 diff --git a/hasura/migrations/1585153829941_update_permission_user_public_table_messages/down.yaml b/hasura/migrations/1585153829941_update_permission_user_public_table_messages/down.yaml new file mode 100644 index 000000000..2c2c6944f --- /dev/null +++ b/hasura/migrations/1585153829941_update_permission_user_public_table_messages/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: messages + schema: public + type: drop_select_permission diff --git a/hasura/migrations/1585153829941_update_permission_user_public_table_messages/up.yaml b/hasura/migrations/1585153829941_update_permission_user_public_table_messages/up.yaml new file mode 100644 index 000000000..02a52dae6 --- /dev/null +++ b/hasura/migrations/1585153829941_update_permission_user_public_table_messages/up.yaml @@ -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 diff --git a/hasura/migrations/1585153837554_update_permission_user_public_table_messages/down.yaml b/hasura/migrations/1585153837554_update_permission_user_public_table_messages/down.yaml new file mode 100644 index 000000000..2a52a80ae --- /dev/null +++ b/hasura/migrations/1585153837554_update_permission_user_public_table_messages/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: messages + schema: public + type: drop_update_permission diff --git a/hasura/migrations/1585153837554_update_permission_user_public_table_messages/up.yaml b/hasura/migrations/1585153837554_update_permission_user_public_table_messages/up.yaml new file mode 100644 index 000000000..6bfebbe3d --- /dev/null +++ b/hasura/migrations/1585153837554_update_permission_user_public_table_messages/up.yaml @@ -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 diff --git a/hasura/migrations/1585153843391_update_permission_user_public_table_messages/down.yaml b/hasura/migrations/1585153843391_update_permission_user_public_table_messages/down.yaml new file mode 100644 index 000000000..c7b5b652b --- /dev/null +++ b/hasura/migrations/1585153843391_update_permission_user_public_table_messages/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: messages + schema: public + type: drop_delete_permission diff --git a/hasura/migrations/1585153843391_update_permission_user_public_table_messages/up.yaml b/hasura/migrations/1585153843391_update_permission_user_public_table_messages/up.yaml new file mode 100644 index 000000000..14905b779 --- /dev/null +++ b/hasura/migrations/1585153843391_update_permission_user_public_table_messages/up.yaml @@ -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 diff --git a/hasura/migrations/1585153926580_create_table_public_job_conversations/down.yaml b/hasura/migrations/1585153926580_create_table_public_job_conversations/down.yaml new file mode 100644 index 000000000..adb6db985 --- /dev/null +++ b/hasura/migrations/1585153926580_create_table_public_job_conversations/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: DROP TABLE "public"."job_conversations"; + type: run_sql diff --git a/hasura/migrations/1585153926580_create_table_public_job_conversations/up.yaml b/hasura/migrations/1585153926580_create_table_public_job_conversations/up.yaml new file mode 100644 index 000000000..1eb5ad992 --- /dev/null +++ b/hasura/migrations/1585153926580_create_table_public_job_conversations/up.yaml @@ -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 diff --git a/hasura/migrations/1585153936524_track_all_relationships/down.yaml b/hasura/migrations/1585153936524_track_all_relationships/down.yaml new file mode 100644 index 000000000..18e9769cb --- /dev/null +++ b/hasura/migrations/1585153936524_track_all_relationships/down.yaml @@ -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 diff --git a/hasura/migrations/1585153936524_track_all_relationships/up.yaml b/hasura/migrations/1585153936524_track_all_relationships/up.yaml new file mode 100644 index 000000000..ddad5f3e9 --- /dev/null +++ b/hasura/migrations/1585153936524_track_all_relationships/up.yaml @@ -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 diff --git a/hasura/migrations/1585154004360_update_permission_user_public_table_job_conversations/down.yaml b/hasura/migrations/1585154004360_update_permission_user_public_table_job_conversations/down.yaml new file mode 100644 index 000000000..3c0c6b457 --- /dev/null +++ b/hasura/migrations/1585154004360_update_permission_user_public_table_job_conversations/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: job_conversations + schema: public + type: drop_insert_permission diff --git a/hasura/migrations/1585154004360_update_permission_user_public_table_job_conversations/up.yaml b/hasura/migrations/1585154004360_update_permission_user_public_table_job_conversations/up.yaml new file mode 100644 index 000000000..5ae11e78e --- /dev/null +++ b/hasura/migrations/1585154004360_update_permission_user_public_table_job_conversations/up.yaml @@ -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 diff --git a/hasura/migrations/1585154010719_update_permission_user_public_table_job_conversations/down.yaml b/hasura/migrations/1585154010719_update_permission_user_public_table_job_conversations/down.yaml new file mode 100644 index 000000000..507bcf27d --- /dev/null +++ b/hasura/migrations/1585154010719_update_permission_user_public_table_job_conversations/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: job_conversations + schema: public + type: drop_select_permission diff --git a/hasura/migrations/1585154010719_update_permission_user_public_table_job_conversations/up.yaml b/hasura/migrations/1585154010719_update_permission_user_public_table_job_conversations/up.yaml new file mode 100644 index 000000000..423d9fc3c --- /dev/null +++ b/hasura/migrations/1585154010719_update_permission_user_public_table_job_conversations/up.yaml @@ -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 diff --git a/hasura/migrations/1585154018518_update_permission_user_public_table_job_conversations/down.yaml b/hasura/migrations/1585154018518_update_permission_user_public_table_job_conversations/down.yaml new file mode 100644 index 000000000..28aa3576d --- /dev/null +++ b/hasura/migrations/1585154018518_update_permission_user_public_table_job_conversations/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: job_conversations + schema: public + type: drop_update_permission diff --git a/hasura/migrations/1585154018518_update_permission_user_public_table_job_conversations/up.yaml b/hasura/migrations/1585154018518_update_permission_user_public_table_job_conversations/up.yaml new file mode 100644 index 000000000..82df37ce8 --- /dev/null +++ b/hasura/migrations/1585154018518_update_permission_user_public_table_job_conversations/up.yaml @@ -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 diff --git a/hasura/migrations/1585154023698_update_permission_user_public_table_job_conversations/down.yaml b/hasura/migrations/1585154023698_update_permission_user_public_table_job_conversations/down.yaml new file mode 100644 index 000000000..a6f9b0b8e --- /dev/null +++ b/hasura/migrations/1585154023698_update_permission_user_public_table_job_conversations/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: job_conversations + schema: public + type: drop_delete_permission diff --git a/hasura/migrations/1585154023698_update_permission_user_public_table_job_conversations/up.yaml b/hasura/migrations/1585154023698_update_permission_user_public_table_job_conversations/up.yaml new file mode 100644 index 000000000..a44463301 --- /dev/null +++ b/hasura/migrations/1585154023698_update_permission_user_public_table_job_conversations/up.yaml @@ -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