IO-1914 Schema for inventory and basic adding to inventory.
This commit is contained in:
@@ -402,6 +402,14 @@
|
||||
- name: jobline
|
||||
using:
|
||||
foreign_key_constraint_on: joblineid
|
||||
array_relationships:
|
||||
- name: inventories
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
column: billlineid
|
||||
table:
|
||||
schema: public
|
||||
name: inventory
|
||||
insert_permissions:
|
||||
- role: user
|
||||
permission:
|
||||
@@ -541,6 +549,13 @@
|
||||
table:
|
||||
schema: public
|
||||
name: exportlog
|
||||
- name: inventories
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
column: consumedbybillid
|
||||
table:
|
||||
schema: public
|
||||
name: inventory
|
||||
- name: parts_orders
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
@@ -751,6 +766,13 @@
|
||||
table:
|
||||
schema: public
|
||||
name: exportlog
|
||||
- name: inventories
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
column: shopid
|
||||
table:
|
||||
schema: public
|
||||
name: inventory
|
||||
- name: jobs
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
@@ -2112,6 +2134,96 @@
|
||||
- active:
|
||||
_eq: true
|
||||
allow_aggregations: true
|
||||
- table:
|
||||
schema: public
|
||||
name: inventory
|
||||
object_relationships:
|
||||
- name: bill
|
||||
using:
|
||||
foreign_key_constraint_on: consumedbybillid
|
||||
- name: billline
|
||||
using:
|
||||
foreign_key_constraint_on: billlineid
|
||||
- name: bodyshop
|
||||
using:
|
||||
foreign_key_constraint_on: shopid
|
||||
- name: jobline
|
||||
using:
|
||||
foreign_key_constraint_on: joblineid
|
||||
insert_permissions:
|
||||
- role: user
|
||||
permission:
|
||||
check:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
columns:
|
||||
- actual_cost
|
||||
- actual_price
|
||||
- billlineid
|
||||
- consumedbybillid
|
||||
- created_at
|
||||
- id
|
||||
- joblineid
|
||||
- line_desc
|
||||
- quantity
|
||||
- shopid
|
||||
- updated_at
|
||||
backend_only: false
|
||||
select_permissions:
|
||||
- role: user
|
||||
permission:
|
||||
columns:
|
||||
- actual_cost
|
||||
- actual_price
|
||||
- billlineid
|
||||
- consumedbybillid
|
||||
- created_at
|
||||
- id
|
||||
- joblineid
|
||||
- line_desc
|
||||
- quantity
|
||||
- shopid
|
||||
- updated_at
|
||||
filter:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
update_permissions:
|
||||
- role: user
|
||||
permission:
|
||||
columns:
|
||||
- actual_cost
|
||||
- actual_price
|
||||
- billlineid
|
||||
- consumedbybillid
|
||||
- created_at
|
||||
- id
|
||||
- joblineid
|
||||
- line_desc
|
||||
- quantity
|
||||
- shopid
|
||||
- updated_at
|
||||
filter:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
check: null
|
||||
- table:
|
||||
schema: public
|
||||
name: ioevents
|
||||
@@ -2211,6 +2323,13 @@
|
||||
table:
|
||||
schema: public
|
||||
name: billlines
|
||||
- name: inventories
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
column: joblineid
|
||||
table:
|
||||
schema: public
|
||||
name: inventory
|
||||
- name: parts_order_lines
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE "public"."inventory";
|
||||
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE "public"."inventory" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "shopid" uuid NOT NULL, "billid" uuid, "joblineid" uuid, "line_desc" text NOT NULL, "actual_price" numeric NOT NULL, "actual_cost" numeric NOT NULL, "quantity" numeric NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("joblineid") REFERENCES "public"."joblines"("id") ON UPDATE restrict ON DELETE restrict);
|
||||
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
|
||||
RETURNS TRIGGER AS $$
|
||||
DECLARE
|
||||
_new record;
|
||||
BEGIN
|
||||
_new := NEW;
|
||||
_new."updated_at" = NOW();
|
||||
RETURN _new;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE TRIGGER "set_public_inventory_updated_at"
|
||||
BEFORE UPDATE ON "public"."inventory"
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
|
||||
COMMENT ON TRIGGER "set_public_inventory_updated_at" ON "public"."inventory"
|
||||
IS 'trigger to set value of column "updated_at" to current timestamp on row update';
|
||||
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."inventory" drop constraint "inventory_billid_fkey";
|
||||
@@ -0,0 +1,5 @@
|
||||
alter table "public"."inventory"
|
||||
add constraint "inventory_billid_fkey"
|
||||
foreign key ("billid")
|
||||
references "public"."billlines"
|
||||
("id") on update restrict on delete restrict;
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."inventory" drop constraint "inventory_shopid_fkey";
|
||||
@@ -0,0 +1,5 @@
|
||||
alter table "public"."inventory"
|
||||
add constraint "inventory_shopid_fkey"
|
||||
foreign key ("shopid")
|
||||
references "public"."bodyshops"
|
||||
("id") on update restrict on delete restrict;
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."inventory" rename column "billlineid" to "billid";
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."inventory" rename column "billid" to "billlineid";
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."inventory" add column "consumedbybillid" uuid
|
||||
-- null;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."inventory" add column "consumedbybillid" uuid
|
||||
null;
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."inventory" drop constraint "inventory_consumedbybillid_fkey";
|
||||
@@ -0,0 +1,5 @@
|
||||
alter table "public"."inventory"
|
||||
add constraint "inventory_consumedbybillid_fkey"
|
||||
foreign key ("consumedbybillid")
|
||||
references "public"."bills"
|
||||
("id") on update restrict on delete restrict;
|
||||
@@ -0,0 +1,5 @@
|
||||
alter table "public"."inventory" drop constraint "inventory_consumedbybillid_fkey",
|
||||
add constraint "inventory_consumedbybillid_fkey"
|
||||
foreign key ("shopid")
|
||||
references "public"."bodyshops"
|
||||
("id") on update restrict on delete restrict;
|
||||
@@ -0,0 +1,5 @@
|
||||
alter table "public"."inventory" drop constraint "inventory_consumedbybillid_fkey",
|
||||
add constraint "inventory_consumedbybillid_fkey"
|
||||
foreign key ("consumedbybillid")
|
||||
references "public"."bills"
|
||||
("id") on update restrict on delete set null;
|
||||
@@ -0,0 +1,5 @@
|
||||
alter table "public"."inventory" drop constraint "inventory_consumedbybillid_fkey",
|
||||
add constraint "inventory_consumedbybillid_fkey"
|
||||
foreign key ("shopid")
|
||||
references "public"."bodyshops"
|
||||
("id") on update restrict on delete restrict;
|
||||
@@ -0,0 +1,5 @@
|
||||
alter table "public"."inventory" drop constraint "inventory_consumedbybillid_fkey",
|
||||
add constraint "inventory_consumedbybillid_fkey"
|
||||
foreign key ("consumedbybillid")
|
||||
references "public"."bills"
|
||||
("id") on update cascade on delete set null;
|
||||
@@ -0,0 +1 @@
|
||||
DROP INDEX IF EXISTS "public"."inventory_consumedbybillid";
|
||||
@@ -0,0 +1,2 @@
|
||||
CREATE INDEX "inventory_consumedbybillid" on
|
||||
"public"."inventory" using btree ("consumedbybillid");
|
||||
@@ -0,0 +1 @@
|
||||
DROP INDEX IF EXISTS "public"."inventory_shopididx";
|
||||
@@ -0,0 +1,2 @@
|
||||
CREATE INDEX "inventory_shopididx" on
|
||||
"public"."inventory" using btree ("shopid");
|
||||
Reference in New Issue
Block a user