Simplify form_list check constraint

This commit is contained in:
Tyler Hallada 2020-10-28 23:56:53 -04:00
parent e482e7764d
commit fb5c78ac4f

View File

@ -30,7 +30,7 @@ CREATE TABLE "merchandise_lists" (
"shop_id" INTEGER REFERENCES "shops"(id) NOT NULL UNIQUE, "shop_id" INTEGER REFERENCES "shops"(id) NOT NULL UNIQUE,
"owner_id" INTEGER REFERENCES "owners"(id) NOT NULL, "owner_id" INTEGER REFERENCES "owners"(id) NOT NULL,
"form_list" jsonb NOT NULL "form_list" jsonb NOT NULL
CONSTRAINT "merchandise_quantity_gt_zero" CHECK (form_list = '[]' OR NOT jsonb_path_exists(form_list, '$[*].quantity ? (@ < 1)')), CONSTRAINT "merchandise_quantity_gt_zero" CHECK (NOT jsonb_path_exists(form_list, '$[*].quantity ? (@ < 1)')),
"created_at" timestamp(3) NOT NULL, "created_at" timestamp(3) NOT NULL,
"updated_at" timestamp(3) NOT NULL "updated_at" timestamp(3) NOT NULL
); );