migration.sql 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. Warnings:
  3. - You are about to drop the `StatusHistory` table. If the table is not empty, all the data it contains will be lost.
  4. */
  5. -- DropForeignKey
  6. ALTER TABLE "StatusHistory" DROP CONSTRAINT "StatusHistory_hospital_id_fkey";
  7. -- DropForeignKey
  8. ALTER TABLE "StatusHistory" DROP CONSTRAINT "StatusHistory_user_id_fkey";
  9. -- DropTable
  10. DROP TABLE "StatusHistory";
  11. -- CreateTable
  12. CREATE TABLE "status_histories" (
  13. "id" TEXT NOT NULL,
  14. "hospital_id" TEXT NOT NULL,
  15. "user_id" TEXT NOT NULL,
  16. "old_status" "ProgressStatus" NOT NULL,
  17. "new_status" "ProgressStatus" NOT NULL,
  18. "notes" TEXT,
  19. "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  20. "updatedAt" TIMESTAMP(3) NOT NULL,
  21. "deletedAt" TIMESTAMP(3),
  22. CONSTRAINT "status_histories_pkey" PRIMARY KEY ("id")
  23. );
  24. -- AddForeignKey
  25. ALTER TABLE "status_histories" ADD CONSTRAINT "status_histories_hospital_id_fkey" FOREIGN KEY ("hospital_id") REFERENCES "hospitals"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
  26. -- AddForeignKey
  27. ALTER TABLE "status_histories" ADD CONSTRAINT "status_histories_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;