-- CreateEnum CREATE TYPE "NotificationKind" AS ENUM ('DAILY_REMINDER', 'MEDICINE_REMINDER', 'INSIGHT_ALERT'); -- CreateTable CREATE TABLE "notifications" ( "id" SERIAL NOT NULL, "kind" "NotificationKind" NOT NULL, "title" TEXT NOT NULL, "body" TEXT NOT NULL, "scheduled_for" TIMESTAMP(3) NOT NULL, "expires_at" TIMESTAMP(3), "pushed_at" TIMESTAMP(3), "regimen_id" INTEGER, "user_id" INTEGER NOT NULL, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "notifications_pkey" PRIMARY KEY ("id") ); -- AddForeignKey ALTER TABLE "notifications" ADD CONSTRAINT "notifications_regimen_id_fkey" FOREIGN KEY ("regimen_id") REFERENCES "medicine_regimens"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "notifications" ADD CONSTRAINT "notifications_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;