refactor: user relation
This commit is contained in:
parent
a74d8b63b1
commit
2bd30b735d
21 changed files with 607 additions and 185 deletions
238
prisma/migrations/20240701062318_user_relation/migration.sql
Normal file
238
prisma/migrations/20240701062318_user_relation/migration.sql
Normal file
|
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `createdBy` on the `Branch` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Branch` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `BranchContact` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `BranchContact` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `BranchUser` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `BranchUser` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `Customer` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Customer` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `CustomerBranch` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `CustomerBranch` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `Employee` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Employee` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `EmployeeCheckup` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `EmployeeCheckup` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `EmployeeHistory` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `EmployeeOtherInfo` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `EmployeeOtherInfo` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `EmployeeWork` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `EmployeeWork` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `Product` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Product` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `ProductGroup` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `ProductGroup` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `ProductType` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `ProductType` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `Service` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Service` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `User` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `User` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `Work` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Work` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `WorkProduct` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `WorkProduct` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Branch" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "BranchContact" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "BranchUser" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Customer" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "CustomerBranch" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Employee" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EmployeeCheckup" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EmployeeHistory" DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EmployeeOtherInfo" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EmployeeWork" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Product" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "ProductGroup" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "ProductType" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Service" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Work" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "WorkProduct" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Branch" ADD CONSTRAINT "Branch_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Branch" ADD CONSTRAINT "Branch_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BranchContact" ADD CONSTRAINT "BranchContact_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BranchContact" ADD CONSTRAINT "BranchContact_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BranchUser" ADD CONSTRAINT "BranchUser_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BranchUser" ADD CONSTRAINT "BranchUser_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "User" ADD CONSTRAINT "User_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "User" ADD CONSTRAINT "User_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Customer" ADD CONSTRAINT "Customer_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Customer" ADD CONSTRAINT "Customer_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CustomerBranch" ADD CONSTRAINT "CustomerBranch_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CustomerBranch" ADD CONSTRAINT "CustomerBranch_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Employee" ADD CONSTRAINT "Employee_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Employee" ADD CONSTRAINT "Employee_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeHistory" ADD CONSTRAINT "EmployeeHistory_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeCheckup" ADD CONSTRAINT "EmployeeCheckup_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeCheckup" ADD CONSTRAINT "EmployeeCheckup_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeWork" ADD CONSTRAINT "EmployeeWork_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeWork" ADD CONSTRAINT "EmployeeWork_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeOtherInfo" ADD CONSTRAINT "EmployeeOtherInfo_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeOtherInfo" ADD CONSTRAINT "EmployeeOtherInfo_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Service" ADD CONSTRAINT "Service_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Service" ADD CONSTRAINT "Service_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Work" ADD CONSTRAINT "Work_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Work" ADD CONSTRAINT "Work_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "WorkProduct" ADD CONSTRAINT "WorkProduct_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "WorkProduct" ADD CONSTRAINT "WorkProduct_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductGroup" ADD CONSTRAINT "ProductGroup_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductGroup" ADD CONSTRAINT "ProductGroup_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductType" ADD CONSTRAINT "ProductType_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductType" ADD CONSTRAINT "ProductType_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Product" ADD CONSTRAINT "Product_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Product" ADD CONSTRAINT "Product_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
Loading…
Add table
Add a link
Reference in a new issue