Nutzer können persönliche Foods anlegen und ändern; der Admin legt zentrale Einträge für alle an. Suche und Namens-Mapping berücksichtigen persönlich, zentral und BLS. Co-authored-by: Cursor <cursoragent@cursor.com>
19 lines
647 B
SQL
19 lines
647 B
SQL
-- Visibility invariant: personal foods have an owner; BLS and central admin foods do not.
|
|
|
|
UPDATE food_catalog
|
|
SET owner_profile_id = NULL
|
|
WHERE catalog_kind IN ('official_bls', 'manual_admin')
|
|
AND owner_profile_id IS NOT NULL;
|
|
|
|
UPDATE food_catalog
|
|
SET is_active = false
|
|
WHERE catalog_kind = 'manual_user'
|
|
AND owner_profile_id IS NULL;
|
|
|
|
ALTER TABLE food_catalog DROP CONSTRAINT IF EXISTS chk_food_catalog_owner;
|
|
|
|
ALTER TABLE food_catalog ADD CONSTRAINT chk_food_catalog_owner CHECK (
|
|
(catalog_kind = 'manual_user' AND owner_profile_id IS NOT NULL)
|
|
OR (catalog_kind IN ('official_bls', 'manual_admin') AND owner_profile_id IS NULL)
|
|
);
|