-- CreateTable CREATE TABLE "notifications" ( "id" UUID NOT NULL, "recipient_employee_id" UUID NOT NULL, "type" VARCHAR(64) NOT NULL, "title" VARCHAR(200) NOT NULL, "body" TEXT, "target_type" VARCHAR(64), "target_id" UUID, "read_at" TIMESTAMP(3), "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "notifications_pkey" PRIMARY KEY ("id") ); -- CreateIndex CREATE INDEX "notifications_recipient_employee_id_created_at_idx" ON "notifications"("recipient_employee_id", "created_at"); -- CreateIndex CREATE INDEX "idx_notifications_unread_query" ON "notifications"("recipient_employee_id", "read_at", "created_at"); -- AddForeignKey ALTER TABLE "notifications" ADD CONSTRAINT "notifications_recipient_employee_id_fkey" FOREIGN KEY ("recipient_employee_id") REFERENCES "employees"("id") ON DELETE CASCADE ON UPDATE CASCADE;