-- v0.19 Pantry: add storedAt, source enum, and plantId to Item

CREATE TYPE "ItemSource" AS ENUM ('GARDEN', 'HOMEMADE', 'STORE', 'FARMERS_MARKET', 'GIFTED', 'OTHER');

ALTER TABLE "Item"
  ADD COLUMN "storedAt"  TIMESTAMP(3),
  ADD COLUMN "source"    "ItemSource",
  ADD COLUMN "plantId"   TEXT;

ALTER TABLE "Item"
  ADD CONSTRAINT "Item_plantId_fkey"
  FOREIGN KEY ("plantId") REFERENCES "Plant"("id")
  ON DELETE SET NULL ON UPDATE CASCADE;

CREATE INDEX "Item_plantId_idx" ON "Item"("plantId");
