Add consignment_detail table for consignment inventory
Separate table linked to product — keeps product table clean when most items are not consignment. Tracks consignor (account), commission percentage, min price, and agreement date. 33 tests passing.
This commit is contained in:
15
packages/backend/src/db/migrations/0006_add_consignment.sql
Normal file
15
packages/backend/src/db/migrations/0006_add_consignment.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE "consignment_detail" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"product_id" uuid NOT NULL,
|
||||
"company_id" uuid NOT NULL,
|
||||
"consignor_account_id" uuid NOT NULL,
|
||||
"commission_percent" numeric(5, 2) NOT NULL,
|
||||
"min_price" numeric(10, 2),
|
||||
"agreement_date" date,
|
||||
"notes" text,
|
||||
"is_active" boolean DEFAULT true NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "consignment_detail" ADD CONSTRAINT "consignment_detail_product_id_product_id_fk" FOREIGN KEY ("product_id") REFERENCES "public"."product"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "consignment_detail" ADD CONSTRAINT "consignment_detail_company_id_company_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."company"("id") ON DELETE no action ON UPDATE no action;
|
||||
1619
packages/backend/src/db/migrations/meta/0006_snapshot.json
Normal file
1619
packages/backend/src/db/migrations/meta/0006_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -43,6 +43,13 @@
|
||||
"when": 1774653515690,
|
||||
"tag": "0005_add_products_units_receipts",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 6,
|
||||
"version": "7",
|
||||
"when": 1774653924179,
|
||||
"tag": "0006_add_consignment",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user