migration.sql 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. Warnings:
  3. - You are about to drop the column `fullname` on the `users` table. All the data in the column will be lost.
  4. - Added the required column `email` to the `users` table without a default value. This is not possible if the table is not empty.
  5. - Added the required column `firstname` to the `users` table without a default value. This is not possible if the table is not empty.
  6. - Added the required column `lastname` to the `users` table without a default value. This is not possible if the table is not empty.
  7. - Added the required column `password` to the `users` table without a default value. This is not possible if the table is not empty.
  8. - Added the required column `role` to the `users` table without a default value. This is not possible if the table is not empty.
  9. - Added the required column `updatedAt` to the `users` table without a default value. This is not possible if the table is not empty.
  10. - Added the required column `username` to the `users` table without a default value. This is not possible if the table is not empty.
  11. */
  12. -- DropForeignKey
  13. ALTER TABLE "hospitals" DROP CONSTRAINT "hospitals_created_by_fkey";
  14. -- AlterTable
  15. ALTER TABLE "users" DROP COLUMN "fullname",
  16. ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  17. ADD COLUMN "deletedAt" TIMESTAMP(3),
  18. ADD COLUMN "email" TEXT NOT NULL,
  19. ADD COLUMN "firstname" TEXT NOT NULL,
  20. ADD COLUMN "lastname" TEXT NOT NULL,
  21. ADD COLUMN "password" TEXT NOT NULL,
  22. ADD COLUMN "role" TEXT NOT NULL,
  23. ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL,
  24. ADD COLUMN "username" TEXT NOT NULL;
  25. -- CreateTable
  26. CREATE TABLE "keycloak_users" (
  27. "id" TEXT NOT NULL,
  28. "fullname" TEXT NOT NULL,
  29. CONSTRAINT "keycloak_users_pkey" PRIMARY KEY ("id")
  30. );
  31. -- AddForeignKey
  32. ALTER TABLE "hospitals" ADD CONSTRAINT "hospitals_created_by_fkey" FOREIGN KEY ("created_by") REFERENCES "keycloak_users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;