feat(ingredients): make units nullable

This commit is contained in:
efrilm
2026-08-11 21:20:17 +07:00
parent 9ae5be2c33
commit 0726fcecf0
11 changed files with 54 additions and 36 deletions
@@ -0,0 +1,6 @@
-- Restoring NOT NULL fails if any ingredient still has a NULL unit_id. Assign a
-- unit to those rows first:
-- SELECT id, name FROM ingredients WHERE unit_id IS NULL;
COMMENT ON COLUMN ingredients.unit_id IS NULL;
ALTER TABLE ingredients ALTER COLUMN unit_id SET NOT NULL;
@@ -0,0 +1,5 @@
-- An ingredient can be registered before its unit has been decided, so unit_id
-- is optional. Existing rows are untouched: they already have a unit.
ALTER TABLE ingredients ALTER COLUMN unit_id DROP NOT NULL;
COMMENT ON COLUMN ingredients.unit_id IS 'Base unit of the ingredient. NULL means no unit has been assigned yet.';