Baseline Schema changes.

This commit is contained in:
Patrick Fic
2019-12-04 20:08:10 -07:00
parent eb41701987
commit 25d434ef10
76 changed files with 5997 additions and 25 deletions

1
hasura/config.yaml Normal file
View File

@@ -0,0 +1 @@
endpoint: https://bodyshop-dev-db.herokuapp.com

View File

@@ -0,0 +1,3 @@
- args:
sql: DROP TABLE "public"."users"
type: run_sql

View File

@@ -0,0 +1,18 @@
- args:
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
sql: "CREATE TABLE \"public\".\"users\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"username\" text NOT NULL, \"password\" text NOT NULL, \"created_at\" timestamptz
NOT NULL DEFAULT now(), \"updated_at\" timestamptz NOT NULL DEFAULT now(), \"last_login\"
timestamptz, PRIMARY KEY (\"id\") );\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_users_updated_at\"\nBEFORE
UPDATE ON \"public\".\"users\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_users_updated_at\" ON \"public\".\"users\" \nIS 'trigger
to set value of column \"updated_at\" to current timestamp on row update';\n"
type: run_sql
- args:
name: users
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,3 @@
- args:
sql: DROP TABLE "public"."bodyshops"
type: run_sql

View File

@@ -0,0 +1,18 @@
- args:
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
sql: "CREATE TABLE \"public\".\"bodyshops\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"shop_name\" text NOT NULL, \"created_at\" timestamptz NOT NULL DEFAULT now(),
\"updated_at\" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (\"id\") );\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_bodyshops_updated_at\"\nBEFORE
UPDATE ON \"public\".\"bodyshops\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_bodyshops_updated_at\" ON \"public\".\"bodyshops\" \nIS
'trigger to set value of column \"updated_at\" to current timestamp on row update';\n"
type: run_sql
- args:
name: bodyshops
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,3 @@
- args:
sql: DROP TABLE "public"."associations"
type: run_sql

View File

@@ -0,0 +1,11 @@
- args:
sql: CREATE TABLE "public"."associations"("bodyshop" uuid NOT NULL, "user" uuid
NOT NULL, "active" boolean NOT NULL DEFAULT false, PRIMARY KEY ("bodyshop","user")
, FOREIGN KEY ("bodyshop") REFERENCES "public"."bodyshops"("id") ON UPDATE restrict
ON DELETE restrict, FOREIGN KEY ("user") REFERENCES "public"."users"("id") ON
UPDATE restrict ON DELETE restrict);
type: run_sql
- args:
name: associations
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,3 @@
- args:
sql: DROP TABLE "public"."estimates"
type: run_sql

View File

@@ -0,0 +1,20 @@
- args:
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
sql: "CREATE TABLE \"public\".\"estimates\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"est_number\" text NOT NULL, \"ro_number\" text NOT
NULL, \"shopid\" uuid NOT NULL, PRIMARY KEY (\"id\") , FOREIGN KEY (\"shopid\")
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_estimates_updated_at\"\nBEFORE
UPDATE ON \"public\".\"estimates\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_estimates_updated_at\" ON \"public\".\"estimates\" \nIS
'trigger to set value of column \"updated_at\" to current timestamp on row update';\n"
type: run_sql
- args:
name: estimates
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,3 @@
- args:
sql: DROP TABLE "public"."estimatelines"
type: run_sql

View File

@@ -0,0 +1,20 @@
- args:
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
sql: "CREATE TABLE \"public\".\"estimatelines\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"estimate_id\" uuid NOT NULL, \"line_desc\" text NOT
NULL, PRIMARY KEY (\"id\") , FOREIGN KEY (\"estimate_id\") REFERENCES \"public\".\"estimates\"(\"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_estimatelines_updated_at\"\nBEFORE
UPDATE ON \"public\".\"estimatelines\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_estimatelines_updated_at\" ON \"public\".\"estimatelines\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';\n"
type: run_sql
- args:
name: estimatelines
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,48 @@
- args:
relationship: userByUser
table:
name: associations
schema: public
type: drop_relationship
- args:
relationship: bodyshopByBodyshop
table:
name: associations
schema: public
type: drop_relationship
- args:
relationship: associations
table:
name: bodyshops
schema: public
type: drop_relationship
- args:
relationship: estimates
table:
name: bodyshops
schema: public
type: drop_relationship
- args:
relationship: estimate
table:
name: estimatelines
schema: public
type: drop_relationship
- args:
relationship: bodyshop
table:
name: estimates
schema: public
type: drop_relationship
- args:
relationship: estimatelines
table:
name: estimates
schema: public
type: drop_relationship
- args:
relationship: associations
table:
name: users
schema: public
type: drop_relationship

View File

@@ -0,0 +1,80 @@
- args:
name: userByUser
table:
name: associations
schema: public
using:
foreign_key_constraint_on: user
type: create_object_relationship
- args:
name: bodyshopByBodyshop
table:
name: associations
schema: public
using:
foreign_key_constraint_on: bodyshop
type: create_object_relationship
- args:
name: associations
table:
name: bodyshops
schema: public
using:
foreign_key_constraint_on:
column: bodyshop
table:
name: associations
schema: public
type: create_array_relationship
- args:
name: estimates
table:
name: bodyshops
schema: public
using:
foreign_key_constraint_on:
column: shopid
table:
name: estimates
schema: public
type: create_array_relationship
- args:
name: estimate
table:
name: estimatelines
schema: public
using:
foreign_key_constraint_on: estimate_id
type: create_object_relationship
- args:
name: bodyshop
table:
name: estimates
schema: public
using:
foreign_key_constraint_on: shopid
type: create_object_relationship
- args:
name: estimatelines
table:
name: estimates
schema: public
using:
foreign_key_constraint_on:
column: estimate_id
table:
name: estimatelines
schema: public
type: create_array_relationship
- args:
name: associations
table:
name: users
schema: public
using:
foreign_key_constraint_on:
column: user
table:
name: associations
schema: public
type: create_array_relationship

View File

@@ -0,0 +1,3 @@
- args:
sql: ALTER TABLE "public"."users" DROP COLUMN "auth0id";
type: run_sql

View File

@@ -0,0 +1,3 @@
- args:
sql: ALTER TABLE "public"."users" ADD COLUMN "auth0id" text NULL;
type: run_sql

View File

@@ -0,0 +1,6 @@
- args:
sql: COMMENT ON COLUMN "public"."users"."auth0id" IS E'null'
type: run_sql
- args:
sql: alter table "public"."users" rename column "authid" to "auth0id";
type: run_sql

View File

@@ -0,0 +1,6 @@
- args:
sql: COMMENT ON COLUMN "public"."users"."auth0id" IS E''
type: run_sql
- args:
sql: alter table "public"."users" rename column "auth0id" to "authid";
type: run_sql

View File

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

View File

@@ -0,0 +1,23 @@
- args:
permission:
allow_upsert: true
check:
authid:
_eq: X-Hasura-User-Id
columns:
- id
- username
- password
- created_at
- updated_at
- last_login
- authid
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: users
schema: public
type: create_insert_permission

View File

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

View File

@@ -0,0 +1,13 @@
- args:
permission:
allow_aggregations: false
columns: []
filter:
authid:
_eq: X-Hasura-User-Id
limit: null
role: user
table:
name: users
schema: public
type: create_select_permission

View File

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

View File

@@ -0,0 +1,15 @@
- args:
permission:
columns: []
filter:
authid:
_eq: X-Hasura-User-Id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: users
schema: public
type: create_update_permission

View File

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

View File

@@ -0,0 +1,10 @@
- args:
permission:
filter:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: users
schema: public
type: create_delete_permission

View File

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

View File

@@ -0,0 +1,22 @@
- args:
permission:
allow_upsert: true
check:
associations:
userByUser:
authid:
_eq: X-Hasura-User-Id
columns:
- id
- shop_name
- created_at
- updated_at
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: bodyshops
schema: public
type: create_insert_permission

View File

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

View File

@@ -0,0 +1,15 @@
- args:
permission:
allow_aggregations: false
columns: []
filter:
associations:
userByUser:
authid:
_eq: X-Hasura-User-Id
limit: null
role: user
table:
name: bodyshops
schema: public
type: create_select_permission

View File

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

View File

@@ -0,0 +1,17 @@
- args:
permission:
columns: []
filter:
associations:
userByUser:
authid:
_eq: X-Hasura-User-Id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: bodyshops
schema: public
type: create_update_permission

View File

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

View File

@@ -0,0 +1,12 @@
- args:
permission:
filter:
associations:
userByUser:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: bodyshops
schema: public
type: create_delete_permission

View File

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

View File

@@ -0,0 +1,20 @@
- args:
permission:
allow_upsert: true
check:
userByUser:
authid:
_eq: X-Hasura-User-Id
columns:
- bodyshop
- user
- active
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: associations
schema: public
type: create_insert_permission

View File

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

View File

@@ -0,0 +1,14 @@
- args:
permission:
allow_aggregations: false
columns: []
filter:
userByUser:
authid:
_eq: X-Hasura-User-Id
limit: null
role: user
table:
name: associations
schema: public
type: create_select_permission

View File

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

View File

@@ -0,0 +1,16 @@
- args:
permission:
columns: []
filter:
userByUser:
authid:
_eq: X-Hasura-User-Id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: associations
schema: public
type: create_update_permission

View File

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

View File

@@ -0,0 +1,11 @@
- args:
permission:
filter:
userByUser:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: associations
schema: public
type: create_delete_permission

View File

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

View File

@@ -0,0 +1,25 @@
- args:
permission:
allow_upsert: true
check:
bodyshop:
associations:
userByUser:
authid:
_eq: X-Hasura-User-Id
columns:
- id
- created_at
- updated_at
- est_number
- ro_number
- shopid
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: estimates
schema: public
type: create_insert_permission

View File

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

View File

@@ -0,0 +1,22 @@
- args:
permission:
allow_aggregations: false
columns:
- est_number
- ro_number
- created_at
- updated_at
- id
- shopid
filter:
bodyshop:
associations:
userByUser:
authid:
_eq: X-Hasura-User-Id
limit: null
role: user
table:
name: estimates
schema: public
type: create_select_permission

View File

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

View File

@@ -0,0 +1,24 @@
- args:
permission:
columns:
- est_number
- ro_number
- created_at
- updated_at
- id
- shopid
filter:
bodyshop:
associations:
userByUser:
authid:
_eq: X-Hasura-User-Id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: estimates
schema: public
type: create_update_permission

View File

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

View File

@@ -0,0 +1,13 @@
- args:
permission:
filter:
bodyshop:
associations:
userByUser:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: estimates
schema: public
type: create_delete_permission

View File

@@ -0,0 +1,20 @@
- args:
role: user
table:
name: associations
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns: []
computed_fields: []
filter:
userByUser:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: associations
schema: public
type: create_select_permission

View File

@@ -0,0 +1,23 @@
- args:
role: user
table:
name: associations
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- bodyshop
- user
- active
computed_fields: []
filter:
userByUser:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: associations
schema: public
type: create_select_permission

View File

@@ -0,0 +1,22 @@
- args:
role: user
table:
name: associations
schema: public
type: drop_update_permission
- args:
permission:
columns: []
filter:
userByUser:
authid:
_eq: X-Hasura-User-Id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: associations
schema: public
type: create_update_permission

View File

@@ -0,0 +1,25 @@
- args:
role: user
table:
name: associations
schema: public
type: drop_update_permission
- args:
permission:
columns:
- active
- bodyshop
- user
filter:
userByUser:
authid:
_eq: X-Hasura-User-Id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: associations
schema: public
type: create_update_permission

View File

@@ -0,0 +1,22 @@
- args:
role: user
table:
name: associations
schema: public
type: drop_update_permission
- args:
permission:
columns: []
filter:
userByUser:
authid:
_eq: X-Hasura-User-Id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: associations
schema: public
type: create_update_permission

View File

@@ -0,0 +1,25 @@
- args:
role: user
table:
name: associations
schema: public
type: drop_update_permission
- args:
permission:
columns:
- active
- bodyshop
- user
filter:
userByUser:
authid:
_eq: X-Hasura-User-Id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: associations
schema: public
type: create_update_permission

View File

@@ -0,0 +1,19 @@
- args:
role: user
table:
name: users
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns: []
computed_fields: []
filter:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: users
schema: public
type: create_select_permission

View File

@@ -0,0 +1,26 @@
- args:
role: user
table:
name: users
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- id
- username
- password
- created_at
- updated_at
- last_login
- authid
computed_fields: []
filter:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: users
schema: public
type: create_select_permission

View File

@@ -0,0 +1,21 @@
- args:
role: user
table:
name: users
schema: public
type: drop_update_permission
- args:
permission:
columns: []
filter:
authid:
_eq: X-Hasura-User-Id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: users
schema: public
type: create_update_permission

View File

@@ -0,0 +1,28 @@
- args:
role: user
table:
name: users
schema: public
type: drop_update_permission
- args:
permission:
columns:
- authid
- password
- username
- created_at
- last_login
- updated_at
- id
filter:
authid:
_eq: X-Hasura-User-Id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: users
schema: public
type: create_update_permission