CREATE TABLE "sku_qty_tiers" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"deal_sku_id" uuid NOT NULL,
	"min_qty" integer NOT NULL,
	"discount_percent" integer NOT NULL,
	"sort_order" integer DEFAULT 0 NOT NULL,
	CONSTRAINT "sku_qty_tiers_min_qty" CHECK ("sku_qty_tiers"."min_qty" >= 2),
	CONSTRAINT "sku_qty_tiers_discount_range" CHECK ("sku_qty_tiers"."discount_percent" BETWEEN 1 AND 100)
);
--> statement-breakpoint
ALTER TABLE "sku_qty_tiers" ADD CONSTRAINT "sku_qty_tiers_deal_sku_id_deal_skus_id_fk" FOREIGN KEY ("deal_sku_id") REFERENCES "public"."deal_skus"("id") ON DELETE cascade ON UPDATE no action;
--> statement-breakpoint
CREATE INDEX "sku_qty_tiers_deal_sku_idx" ON "sku_qty_tiers" USING btree ("deal_sku_id");
