46a1911c1c
Uniform stock management for healthcare linen rooms: the coordinator app, the phone counter and the staff app, for your own server. Built from 5470a36 on 2026-09-13. Licensed under the Functional Source License (FSL-1.1-ALv2).
23 lines
1.0 KiB
SQL
23 lines
1.0 KiB
SQL
-- A garment can be for several staff groups.
|
|
--
|
|
-- A catalogue item carried one group name, or "All", so a scrub top worn by four nursing groups had
|
|
-- to be marked for everybody or entered four times. It now carries a list, and an EMPTY list means
|
|
-- every group — what "All" meant.
|
|
--
|
|
-- Every garment keeps exactly the group it has: "All" or blank becomes the empty list, any other
|
|
-- name a list of that one name. Only then does the old column go.
|
|
ALTER TABLE "CatalogItem" ADD COLUMN "groups" TEXT[] DEFAULT ARRAY[]::TEXT[];
|
|
|
|
UPDATE "CatalogItem"
|
|
SET "groups" = CASE
|
|
WHEN lower(btrim("group")) IN ('', 'all') THEN ARRAY[]::TEXT[]
|
|
ELSE ARRAY[btrim("group")]
|
|
END;
|
|
|
|
ALTER TABLE "CatalogItem" DROP COLUMN "group";
|
|
|
|
-- A garment issued outside the person's own staff group on the coordinator's override. Its own flag
|
|
-- rather than "override", which is the six-set ceiling's, so the record tells the two apart. Every
|
|
-- existing issue predates the rule and is not one.
|
|
ALTER TABLE "Issue" ADD COLUMN "offGroup" BOOLEAN NOT NULL DEFAULT false;
|