Files
ubi-dan-itam/prisma/migrations/20260731075828_relate_request_to_employee/migration.sql
T
toanhoang 49d96b77e8 feat: relate Request.employee_id to Employee via FK
Retrofits Request.employeeId from a free-text String with no
referential integrity to a real relation: employeeId String @db.Uuid
+ employee Employee @relation(...), plus the inverse Employee.requests
back-relation field. Migration alters requests.employee_id from TEXT
to UUID with an FK constraint (drop+recreate, confirmed empty table -
no production/dev data existed to migrate).
2026-07-31 14:58:47 +07:00

13 lines
498 B
SQL

/*
Warnings:
- Changed the type of `employee_id` on the `requests` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
*/
-- AlterTable
ALTER TABLE "requests" DROP COLUMN "employee_id",
ADD COLUMN "employee_id" UUID NOT NULL;
-- AddForeignKey
ALTER TABLE "requests" ADD CONSTRAINT "requests_employee_id_fkey" FOREIGN KEY ("employee_id") REFERENCES "employees"("id") ON DELETE RESTRICT ON UPDATE CASCADE;