diff --git a/hasura/migrations/1619132732600_create_table_public_phonebook/down.yaml b/hasura/migrations/1619132732600_create_table_public_phonebook/down.yaml new file mode 100644 index 000000000..af66f8d33 --- /dev/null +++ b/hasura/migrations/1619132732600_create_table_public_phonebook/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: DROP TABLE "public"."phonebook"; + type: run_sql diff --git a/hasura/migrations/1619132732600_create_table_public_phonebook/up.yaml b/hasura/migrations/1619132732600_create_table_public_phonebook/up.yaml new file mode 100644 index 000000000..fd0763cd7 --- /dev/null +++ b/hasura/migrations/1619132732600_create_table_public_phonebook/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\".\"phonebook\"(\"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, \"type\" text NOT NULL, + \"firstname\" text, \"lastname\" text, \"phone1\" text, \"email\" text, \"address1\" + text, \"address2\" text, \"city\" text, \"state\" text, \"zip\" text, \"country\" + text, \"company\" text, \"phone2\" text, \"fax\" text, \"category\" text, 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_phonebook_updated_at\"\nBEFORE + UPDATE ON \"public\".\"phonebook\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT + ON TRIGGER \"set_public_phonebook_updated_at\" ON \"public\".\"phonebook\" \nIS + 'trigger to set value of column \"updated_at\" to current timestamp on row update';" + type: run_sql +- args: + name: phonebook + schema: public + type: add_existing_table_or_view diff --git a/hasura/migrations/1619132753494_track_all_relationships/down.yaml b/hasura/migrations/1619132753494_track_all_relationships/down.yaml new file mode 100644 index 000000000..4e58433b9 --- /dev/null +++ b/hasura/migrations/1619132753494_track_all_relationships/down.yaml @@ -0,0 +1,12 @@ +- args: + relationship: phonebooks + table: + name: bodyshops + schema: public + type: drop_relationship +- args: + relationship: bodyshop + table: + name: phonebook + schema: public + type: drop_relationship diff --git a/hasura/migrations/1619132753494_track_all_relationships/up.yaml b/hasura/migrations/1619132753494_track_all_relationships/up.yaml new file mode 100644 index 000000000..c645985c6 --- /dev/null +++ b/hasura/migrations/1619132753494_track_all_relationships/up.yaml @@ -0,0 +1,20 @@ +- args: + name: phonebooks + table: + name: bodyshops + schema: public + using: + foreign_key_constraint_on: + column: bodyshopid + table: + name: phonebook + schema: public + type: create_array_relationship +- args: + name: bodyshop + table: + name: phonebook + schema: public + using: + foreign_key_constraint_on: bodyshopid + type: create_object_relationship diff --git a/hasura/migrations/1619132868980_update_permission_user_public_table_phonebook/down.yaml b/hasura/migrations/1619132868980_update_permission_user_public_table_phonebook/down.yaml new file mode 100644 index 000000000..c224bad45 --- /dev/null +++ b/hasura/migrations/1619132868980_update_permission_user_public_table_phonebook/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: phonebook + schema: public + type: drop_insert_permission diff --git a/hasura/migrations/1619132868980_update_permission_user_public_table_phonebook/up.yaml b/hasura/migrations/1619132868980_update_permission_user_public_table_phonebook/up.yaml new file mode 100644 index 000000000..72a6fa068 --- /dev/null +++ b/hasura/migrations/1619132868980_update_permission_user_public_table_phonebook/up.yaml @@ -0,0 +1,39 @@ +- 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 + - bodyshopid + - type + - firstname + - lastname + - phone1 + - email + - address1 + - address2 + - city + - state + - zip + - country + - company + - phone2 + - fax + - category + set: {} + role: user + table: + name: phonebook + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1619132880293_update_permission_user_public_table_phonebook/down.yaml b/hasura/migrations/1619132880293_update_permission_user_public_table_phonebook/down.yaml new file mode 100644 index 000000000..843a6e1bc --- /dev/null +++ b/hasura/migrations/1619132880293_update_permission_user_public_table_phonebook/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: phonebook + schema: public + type: drop_select_permission diff --git a/hasura/migrations/1619132880293_update_permission_user_public_table_phonebook/up.yaml b/hasura/migrations/1619132880293_update_permission_user_public_table_phonebook/up.yaml new file mode 100644 index 000000000..b3a818972 --- /dev/null +++ b/hasura/migrations/1619132880293_update_permission_user_public_table_phonebook/up.yaml @@ -0,0 +1,40 @@ +- args: + permission: + allow_aggregations: false + backend_only: false + columns: + - address1 + - address2 + - category + - city + - company + - country + - email + - fax + - firstname + - lastname + - phone1 + - phone2 + - state + - type + - zip + - 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: phonebook + schema: public + type: create_select_permission diff --git a/hasura/migrations/1619132893252_update_permission_user_public_table_phonebook/down.yaml b/hasura/migrations/1619132893252_update_permission_user_public_table_phonebook/down.yaml new file mode 100644 index 000000000..a5c894d75 --- /dev/null +++ b/hasura/migrations/1619132893252_update_permission_user_public_table_phonebook/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: phonebook + schema: public + type: drop_update_permission diff --git a/hasura/migrations/1619132893252_update_permission_user_public_table_phonebook/up.yaml b/hasura/migrations/1619132893252_update_permission_user_public_table_phonebook/up.yaml new file mode 100644 index 000000000..aa4b3f52e --- /dev/null +++ b/hasura/migrations/1619132893252_update_permission_user_public_table_phonebook/up.yaml @@ -0,0 +1,38 @@ +- args: + permission: + backend_only: false + columns: + - address1 + - address2 + - category + - city + - company + - country + - email + - fax + - firstname + - lastname + - phone1 + - phone2 + - state + - type + - zip + - created_at + - updated_at + - bodyshopid + - id + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: phonebook + schema: public + type: create_update_permission diff --git a/hasura/migrations/1619133503127_alter_table_public_phonebook_alter_column_type/down.yaml b/hasura/migrations/1619133503127_alter_table_public_phonebook_alter_column_type/down.yaml new file mode 100644 index 000000000..b7ca6f5d4 --- /dev/null +++ b/hasura/migrations/1619133503127_alter_table_public_phonebook_alter_column_type/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."phonebook" ALTER COLUMN "type" SET NOT NULL; + type: run_sql diff --git a/hasura/migrations/1619133503127_alter_table_public_phonebook_alter_column_type/up.yaml b/hasura/migrations/1619133503127_alter_table_public_phonebook_alter_column_type/up.yaml new file mode 100644 index 000000000..821498c2b --- /dev/null +++ b/hasura/migrations/1619133503127_alter_table_public_phonebook_alter_column_type/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."phonebook" ALTER COLUMN "type" DROP NOT NULL; + type: run_sql diff --git a/hasura/migrations/1619133535893_alter_table_public_phonebook_drop_column_type/down.yaml b/hasura/migrations/1619133535893_alter_table_public_phonebook_drop_column_type/down.yaml new file mode 100644 index 000000000..076c8d398 --- /dev/null +++ b/hasura/migrations/1619133535893_alter_table_public_phonebook_drop_column_type/down.yaml @@ -0,0 +1,10 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."phonebook" ADD COLUMN "type" text; + type: run_sql +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."phonebook" ALTER COLUMN "type" DROP NOT NULL; + type: run_sql diff --git a/hasura/migrations/1619133535893_alter_table_public_phonebook_drop_column_type/up.yaml b/hasura/migrations/1619133535893_alter_table_public_phonebook_drop_column_type/up.yaml new file mode 100644 index 000000000..65544dfd6 --- /dev/null +++ b/hasura/migrations/1619133535893_alter_table_public_phonebook_drop_column_type/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: true + read_only: false + sql: ALTER TABLE "public"."phonebook" DROP COLUMN "type" CASCADE; + type: run_sql diff --git a/hasura/migrations/1619133576648_update_permission_user_public_table_phonebook/down.yaml b/hasura/migrations/1619133576648_update_permission_user_public_table_phonebook/down.yaml new file mode 100644 index 000000000..c224bad45 --- /dev/null +++ b/hasura/migrations/1619133576648_update_permission_user_public_table_phonebook/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: phonebook + schema: public + type: drop_insert_permission diff --git a/hasura/migrations/1619133576648_update_permission_user_public_table_phonebook/up.yaml b/hasura/migrations/1619133576648_update_permission_user_public_table_phonebook/up.yaml new file mode 100644 index 000000000..e03d0c6da --- /dev/null +++ b/hasura/migrations/1619133576648_update_permission_user_public_table_phonebook/up.yaml @@ -0,0 +1,38 @@ +- 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 + - bodyshopid + - firstname + - lastname + - phone1 + - email + - address1 + - address2 + - city + - state + - zip + - country + - company + - phone2 + - fax + - category + set: {} + role: user + table: + name: phonebook + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1619133588241_update_permission_user_public_table_phonebook/down.yaml b/hasura/migrations/1619133588241_update_permission_user_public_table_phonebook/down.yaml new file mode 100644 index 000000000..843a6e1bc --- /dev/null +++ b/hasura/migrations/1619133588241_update_permission_user_public_table_phonebook/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: phonebook + schema: public + type: drop_select_permission diff --git a/hasura/migrations/1619133588241_update_permission_user_public_table_phonebook/up.yaml b/hasura/migrations/1619133588241_update_permission_user_public_table_phonebook/up.yaml new file mode 100644 index 000000000..f5eb078c3 --- /dev/null +++ b/hasura/migrations/1619133588241_update_permission_user_public_table_phonebook/up.yaml @@ -0,0 +1,39 @@ +- args: + permission: + allow_aggregations: false + backend_only: false + columns: + - address1 + - address2 + - category + - city + - company + - country + - email + - fax + - firstname + - lastname + - phone1 + - phone2 + - state + - zip + - 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: phonebook + schema: public + type: create_select_permission diff --git a/hasura/migrations/1619133601763_update_permission_user_public_table_phonebook/down.yaml b/hasura/migrations/1619133601763_update_permission_user_public_table_phonebook/down.yaml new file mode 100644 index 000000000..a5c894d75 --- /dev/null +++ b/hasura/migrations/1619133601763_update_permission_user_public_table_phonebook/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: phonebook + schema: public + type: drop_update_permission diff --git a/hasura/migrations/1619133601763_update_permission_user_public_table_phonebook/up.yaml b/hasura/migrations/1619133601763_update_permission_user_public_table_phonebook/up.yaml new file mode 100644 index 000000000..93866573b --- /dev/null +++ b/hasura/migrations/1619133601763_update_permission_user_public_table_phonebook/up.yaml @@ -0,0 +1,37 @@ +- args: + permission: + backend_only: false + columns: + - address1 + - address2 + - category + - city + - company + - country + - email + - fax + - firstname + - lastname + - phone1 + - phone2 + - state + - zip + - created_at + - updated_at + - bodyshopid + - id + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: phonebook + schema: public + type: create_update_permission diff --git a/hasura/migrations/1619133694446_run_sql_migration/down.yaml b/hasura/migrations/1619133694446_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1619133694446_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1619133694446_run_sql_migration/up.yaml b/hasura/migrations/1619133694446_run_sql_migration/up.yaml new file mode 100644 index 000000000..3b488acd3 --- /dev/null +++ b/hasura/migrations/1619133694446_run_sql_migration/up.yaml @@ -0,0 +1,26 @@ +- args: + cascade: false + read_only: false + sql: "CREATE OR REPLACE FUNCTION public.search_phonebook (search text)\n\tRETURNS + SETOF phonebook\n\tLANGUAGE plpgsql\n\tSTABLE\n\tAS $function$\nBEGIN\n\tIF + search = '' THEN\n\t\tRETURN query\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\tphonebook;\n\tELSE\n\t\tRETURN + query\n\t\tSELECT\n\t\t\tbills.*\n\t\tFROM\n\t\t\tphonebook\n\t\tWHERE firstname + ILIKE '%' || search || '%'\n\t\t\tOR lastname ILIKE '%' || search || '%'\n\t\t\tOR + company ILIKE '%' || search || '%'\n\t\t\tOR address1 ILIKE '%' || search || + '%'\n\t\t\tOR phone1 ILIKE '%' || search || '%'\n\t\t\tOR phone2 ILIKE '%' || + search || '%'\n\t\t\tOR email ILIKE '%' || search || '%'\n\t\t\tOR category + ILIKE '%' || search || '%'\n\t\tORDER BY\n\t\t\n\t\t\tfirstname ILIKE '%' || + search || '%'\n\t\t\tOR NULL,\n\t\t\tlastname ILIKE '%' || search || '%'\n\t\t\tOR + NULL,\n\t\t\tcompany ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\taddress1 + ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\tphone1 ILIKE '%' || search + || '%'\n\t\t\tOR NULL,\n\t\t\tphone2 ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\temail + ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\tcategory ILIKE '%' || search + || '%'\n\t\t\tOR NULL,\n\t\t\townr_addr1 ILIKE '%' || search || '%'\n\t\t\tOR + NULL,\n\t\t\townr_addr1 ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\townr_addr1 + ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\townr_addr1 ILIKE '%' || search + || '%'\n\t\t\tOR NULL;\n\tEND IF;\nEND\n$function$;" + type: run_sql +- args: + name: search_phonebook + schema: public + type: track_function diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index 8e50cc15e..3268efc56 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -719,6 +719,13 @@ tables: table: schema: public name: owners + - name: phonebooks + using: + foreign_key_constraint_on: + column: bodyshopid + table: + schema: public + name: phonebook - name: timetickets using: foreign_key_constraint_on: @@ -3777,6 +3784,108 @@ tables: _eq: X-Hasura-User-Id - active: _eq: true +- table: + schema: public + name: phonebook + object_relationships: + - name: bodyshop + using: + foreign_key_constraint_on: bodyshopid + 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 + - bodyshopid + - firstname + - lastname + - phone1 + - email + - address1 + - address2 + - city + - state + - zip + - country + - company + - phone2 + - fax + - category + backend_only: false + select_permissions: + - role: user + permission: + columns: + - address1 + - address2 + - category + - city + - company + - country + - email + - fax + - firstname + - lastname + - phone1 + - phone2 + - state + - zip + - 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: + - address1 + - address2 + - category + - city + - company + - country + - email + - fax + - firstname + - lastname + - phone1 + - phone2 + - state + - zip + - created_at + - updated_at + - bodyshopid + - id + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + check: null - table: schema: public name: scoreboard @@ -4349,6 +4458,9 @@ functions: - function: schema: public name: search_payments +- function: + schema: public + name: search_phonebook - function: schema: public name: search_vehicles