From 985d0669788e772788592b8141d005fc5685e411 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Tue, 20 May 2025 12:49:32 -0400 Subject: [PATCH] feature/IO-3182-Phone-Number-Consent - Finish Database changes --- hasura/metadata/tables.yaml | 37 +++++++++++++++++++ .../down.sql | 1 + .../up.sql | 2 + 3 files changed, 40 insertions(+) create mode 100644 hasura/migrations/1747759446622_create_table_public_phone_number_consent_history/down.sql create mode 100644 hasura/migrations/1747759446622_create_table_public_phone_number_consent_history/up.sql diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 1b4faac05..17c162e07 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -5870,6 +5870,14 @@ - name: bodyshop using: foreign_key_constraint_on: bodyshopid + array_relationships: + - name: phone_number_consent_histories + using: + foreign_key_constraint_on: + column: phone_number_consent_id + table: + name: phone_number_consent_history + schema: public insert_permissions: - role: user permission: @@ -5925,6 +5933,35 @@ filter: {} check: null comment: "" +- table: + name: phone_number_consent_history + schema: public + object_relationships: + - name: phone_number_consent + using: + foreign_key_constraint_on: phone_number_consent_id + select_permissions: + - role: user + permission: + columns: + - new_value + - old_value + - changed_by + - reason + - changed_at + - id + - phone_number_consent_id + filter: + phone_number_consent: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + comment: "" - table: name: phonebook schema: public diff --git a/hasura/migrations/1747759446622_create_table_public_phone_number_consent_history/down.sql b/hasura/migrations/1747759446622_create_table_public_phone_number_consent_history/down.sql new file mode 100644 index 000000000..311862382 --- /dev/null +++ b/hasura/migrations/1747759446622_create_table_public_phone_number_consent_history/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."phone_number_consent_history"; diff --git a/hasura/migrations/1747759446622_create_table_public_phone_number_consent_history/up.sql b/hasura/migrations/1747759446622_create_table_public_phone_number_consent_history/up.sql new file mode 100644 index 000000000..10a07721f --- /dev/null +++ b/hasura/migrations/1747759446622_create_table_public_phone_number_consent_history/up.sql @@ -0,0 +1,2 @@ +CREATE TABLE "public"."phone_number_consent_history" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "phone_number_consent_id" uuid NOT NULL, "old_value" boolean NOT NULL, "new_value" boolean NOT NULL, "reason" text NOT NULL, "changed_at" timestamptz NOT NULL DEFAULT now(), "changed_by" text NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("phone_number_consent_id") REFERENCES "public"."phone_number_consent"("id") ON UPDATE restrict ON DELETE restrict, UNIQUE ("id")); +CREATE EXTENSION IF NOT EXISTS pgcrypto;