-- CreateTable
CREATE TABLE "meal_menus" (
    "id" TEXT NOT NULL,
    "tenant_id" TEXT NOT NULL,
    "menu_date" DATE NOT NULL,
    "breakfast" TEXT,
    "lunch" TEXT,
    "afternoon_snack" TEXT,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "created_by_user_id" TEXT,

    CONSTRAINT "meal_menus_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "meal_menus_tenant_id_menu_date_key" ON "meal_menus"("tenant_id", "menu_date");

-- CreateIndex
CREATE INDEX "meal_menus_tenant_id_menu_date_idx" ON "meal_menus"("tenant_id", "menu_date");

-- AddForeignKey
ALTER TABLE "meal_menus" ADD CONSTRAINT "meal_menus_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "meal_menus" ADD CONSTRAINT "meal_menus_created_by_user_id_fkey" FOREIGN KEY ("created_by_user_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
