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).
13 lines
498 B
SQL
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;
|