IO-924 Phonebook Migrations
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
- args:
|
||||||
|
cascade: false
|
||||||
|
read_only: false
|
||||||
|
sql: DROP TABLE "public"."phonebook";
|
||||||
|
type: run_sql
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
- args:
|
||||||
|
role: user
|
||||||
|
table:
|
||||||
|
name: phonebook
|
||||||
|
schema: public
|
||||||
|
type: drop_insert_permission
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
- args:
|
||||||
|
role: user
|
||||||
|
table:
|
||||||
|
name: phonebook
|
||||||
|
schema: public
|
||||||
|
type: drop_select_permission
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
- args:
|
||||||
|
role: user
|
||||||
|
table:
|
||||||
|
name: phonebook
|
||||||
|
schema: public
|
||||||
|
type: drop_update_permission
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
- args:
|
||||||
|
cascade: false
|
||||||
|
read_only: false
|
||||||
|
sql: ALTER TABLE "public"."phonebook" ALTER COLUMN "type" SET NOT NULL;
|
||||||
|
type: run_sql
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
- args:
|
||||||
|
cascade: false
|
||||||
|
read_only: false
|
||||||
|
sql: ALTER TABLE "public"."phonebook" ALTER COLUMN "type" DROP NOT NULL;
|
||||||
|
type: run_sql
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
- args:
|
||||||
|
cascade: true
|
||||||
|
read_only: false
|
||||||
|
sql: ALTER TABLE "public"."phonebook" DROP COLUMN "type" CASCADE;
|
||||||
|
type: run_sql
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
- args:
|
||||||
|
role: user
|
||||||
|
table:
|
||||||
|
name: phonebook
|
||||||
|
schema: public
|
||||||
|
type: drop_insert_permission
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
- args:
|
||||||
|
role: user
|
||||||
|
table:
|
||||||
|
name: phonebook
|
||||||
|
schema: public
|
||||||
|
type: drop_select_permission
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
- args:
|
||||||
|
role: user
|
||||||
|
table:
|
||||||
|
name: phonebook
|
||||||
|
schema: public
|
||||||
|
type: drop_update_permission
|
||||||
@@ -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
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
[]
|
||||||
26
hasura/migrations/1619133694446_run_sql_migration/up.yaml
Normal file
26
hasura/migrations/1619133694446_run_sql_migration/up.yaml
Normal 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
|
||||||
@@ -719,6 +719,13 @@ tables:
|
|||||||
table:
|
table:
|
||||||
schema: public
|
schema: public
|
||||||
name: owners
|
name: owners
|
||||||
|
- name: phonebooks
|
||||||
|
using:
|
||||||
|
foreign_key_constraint_on:
|
||||||
|
column: bodyshopid
|
||||||
|
table:
|
||||||
|
schema: public
|
||||||
|
name: phonebook
|
||||||
- name: timetickets
|
- name: timetickets
|
||||||
using:
|
using:
|
||||||
foreign_key_constraint_on:
|
foreign_key_constraint_on:
|
||||||
@@ -3777,6 +3784,108 @@ tables:
|
|||||||
_eq: X-Hasura-User-Id
|
_eq: X-Hasura-User-Id
|
||||||
- active:
|
- active:
|
||||||
_eq: true
|
_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:
|
- table:
|
||||||
schema: public
|
schema: public
|
||||||
name: scoreboard
|
name: scoreboard
|
||||||
@@ -4349,6 +4458,9 @@ functions:
|
|||||||
- function:
|
- function:
|
||||||
schema: public
|
schema: public
|
||||||
name: search_payments
|
name: search_payments
|
||||||
|
- function:
|
||||||
|
schema: public
|
||||||
|
name: search_phonebook
|
||||||
- function:
|
- function:
|
||||||
schema: public
|
schema: public
|
||||||
name: search_vehicles
|
name: search_vehicles
|
||||||
|
|||||||
Reference in New Issue
Block a user