44 lines
1.7 KiB
SQL
44 lines
1.7 KiB
SQL
/*
|
|
Warnings:
|
|
|
|
- The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
- You are about to drop the column `id` on the `User` table. All the data in the column will be lost.
|
|
- Made the column `nwkennung` on table `User` required. This step will fail if there are existing NULL values in that column.
|
|
|
|
*/
|
|
-- DropForeignKey
|
|
ALTER TABLE "Device" DROP CONSTRAINT "Device_createdById_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "Device" DROP CONSTRAINT "Device_updatedById_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "DeviceHistory" DROP CONSTRAINT "DeviceHistory_changedById_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "UserRole" DROP CONSTRAINT "UserRole_userId_fkey";
|
|
|
|
-- DropIndex
|
|
DROP INDEX "Device_inventoryNumber_key";
|
|
|
|
-- DropIndex
|
|
DROP INDEX "User_nwkennung_key";
|
|
|
|
-- AlterTable
|
|
ALTER TABLE "User" DROP CONSTRAINT "User_pkey",
|
|
DROP COLUMN "id",
|
|
ALTER COLUMN "nwkennung" SET NOT NULL,
|
|
ADD CONSTRAINT "User_pkey" PRIMARY KEY ("nwkennung");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "UserRole" ADD CONSTRAINT "UserRole_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("nwkennung") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Device" ADD CONSTRAINT "Device_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("nwkennung") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Device" ADD CONSTRAINT "Device_updatedById_fkey" FOREIGN KEY ("updatedById") REFERENCES "User"("nwkennung") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "DeviceHistory" ADD CONSTRAINT "DeviceHistory_changedById_fkey" FOREIGN KEY ("changedById") REFERENCES "User"("nwkennung") ON DELETE SET NULL ON UPDATE CASCADE;
|