IO-924 Phonebook Migrations

This commit is contained in:
Patrick Fic
2021-04-22 16:23:32 -07:00
parent be6ff42e57
commit 084c7d9c74
23 changed files with 494 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: DROP TABLE "public"."phonebook";
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\".\"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

View File

@@ -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

View File

@@ -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

View File

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

View File

@@ -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

View File

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

View File

@@ -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

View File

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

View File

@@ -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

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."phonebook" ALTER COLUMN "type" SET NOT NULL;
type: run_sql

View File

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

View File

@@ -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

View File

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

View File

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

View File

@@ -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

View File

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

View File

@@ -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

View File

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

View File

@@ -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

View File

@@ -0,0 +1 @@
[]

View File

@@ -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

View File

@@ -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