chore: update db
This commit is contained in:
parent
326f7692c0
commit
eaa41f49be
3 changed files with 230 additions and 2 deletions
119
prisma/migrations/20240417063829_update_table/migration.sql
Normal file
119
prisma/migrations/20240417063829_update_table/migration.sql
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `telephoneNo` on the `Branch` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Branch" DROP COLUMN "telephoneNo";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Menu" (
|
||||
"id" TEXT NOT NULL,
|
||||
"caption" TEXT NOT NULL,
|
||||
"captionEN" TEXT NOT NULL,
|
||||
"menuType" TEXT NOT NULL,
|
||||
"url" TEXT NOT NULL,
|
||||
"createdBy" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updateBy" TEXT,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"parentId" TEXT,
|
||||
|
||||
CONSTRAINT "Menu_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "RoleMenuPermission" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userRole" TEXT NOT NULL,
|
||||
"permission" TEXT NOT NULL,
|
||||
"menuId" TEXT NOT NULL,
|
||||
"createdBy" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updateBy" TEXT,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "RoleMenuPermission_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "UserMenuPermission" (
|
||||
"id" TEXT NOT NULL,
|
||||
"permission" TEXT NOT NULL,
|
||||
"menuId" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"createdBy" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updateBy" TEXT,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "UserMenuPermission_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "MenuComponent" (
|
||||
"id" TEXT NOT NULL,
|
||||
"componentId" TEXT NOT NULL,
|
||||
"componentTag" TEXT NOT NULL,
|
||||
"menuId" TEXT NOT NULL,
|
||||
"createdBy" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updateBy" TEXT,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "MenuComponent_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "RoleMenuComponentPermission" (
|
||||
"id" TEXT NOT NULL,
|
||||
"componentId" TEXT NOT NULL,
|
||||
"componentTag" TEXT NOT NULL,
|
||||
"menuComponentId" TEXT NOT NULL,
|
||||
"permission" TEXT NOT NULL,
|
||||
"createdBy" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updateBy" TEXT,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "RoleMenuComponentPermission_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "UserMenuComponentPermission" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"menuComponentId" TEXT NOT NULL,
|
||||
"permission" TEXT NOT NULL,
|
||||
"createdBy" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updateBy" TEXT,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "UserMenuComponentPermission_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Menu" ADD CONSTRAINT "Menu_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Menu"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "RoleMenuPermission" ADD CONSTRAINT "RoleMenuPermission_menuId_fkey" FOREIGN KEY ("menuId") REFERENCES "Menu"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "UserMenuPermission" ADD CONSTRAINT "UserMenuPermission_menuId_fkey" FOREIGN KEY ("menuId") REFERENCES "Menu"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "UserMenuPermission" ADD CONSTRAINT "UserMenuPermission_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "MenuComponent" ADD CONSTRAINT "MenuComponent_menuId_fkey" FOREIGN KEY ("menuId") REFERENCES "Menu"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "RoleMenuComponentPermission" ADD CONSTRAINT "RoleMenuComponentPermission_menuComponentId_fkey" FOREIGN KEY ("menuComponentId") REFERENCES "MenuComponent"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "UserMenuComponentPermission" ADD CONSTRAINT "UserMenuComponentPermission_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "UserMenuComponentPermission" ADD CONSTRAINT "UserMenuComponentPermission_menuComponentId_fkey" FOREIGN KEY ("menuComponentId") REFERENCES "MenuComponent"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "Branch" ADD COLUMN "contactName" TEXT;
|
||||
|
|
@ -7,6 +7,111 @@ datasource db {
|
|||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Menu {
|
||||
id String @id @default(uuid())
|
||||
|
||||
caption String
|
||||
captionEN String
|
||||
menuType String
|
||||
url String
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
parent Menu? @relation(name: "MenuRelation", fields: [parentId], references: [id])
|
||||
parentId String?
|
||||
|
||||
children Menu[] @relation(name: "MenuRelation")
|
||||
roleMenuPermission RoleMenuPermission[]
|
||||
userMenuPermission UserMenuPermission[]
|
||||
userComponent MenuComponent[]
|
||||
}
|
||||
|
||||
model RoleMenuPermission {
|
||||
id String @id @default(uuid())
|
||||
|
||||
userRole String
|
||||
permission String
|
||||
|
||||
menu Menu @relation(fields: [menuId], references: [id])
|
||||
menuId String
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model UserMenuPermission {
|
||||
id String @id @default(uuid())
|
||||
|
||||
permission String
|
||||
|
||||
menu Menu @relation(fields: [menuId], references: [id])
|
||||
menuId String
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model MenuComponent {
|
||||
id String @id @default(uuid())
|
||||
|
||||
componentId String
|
||||
componentTag String
|
||||
|
||||
menu Menu @relation(fields: [menuId], references: [id])
|
||||
menuId String
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
roleMenuComponentPermission RoleMenuComponentPermission[]
|
||||
userMennuComponentPermission UserMenuComponentPermission[]
|
||||
}
|
||||
|
||||
model RoleMenuComponentPermission {
|
||||
id String @id @default(uuid())
|
||||
|
||||
componentId String
|
||||
componentTag String
|
||||
|
||||
menuComponent MenuComponent @relation(fields: [menuComponentId], references: [id])
|
||||
menuComponentId String
|
||||
|
||||
permission String
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model UserMenuComponentPermission {
|
||||
id String @id @default(uuid())
|
||||
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
|
||||
menuComponent MenuComponent @relation(fields: [menuComponentId], references: [id])
|
||||
menuComponentId String
|
||||
|
||||
permission String
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Province {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
|
|
@ -92,7 +197,7 @@ model Branch {
|
|||
zipCode String
|
||||
|
||||
email String
|
||||
telephoneNo String
|
||||
contactName String?
|
||||
lineId String?
|
||||
|
||||
latitude String
|
||||
|
|
@ -206,7 +311,9 @@ model User {
|
|||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
branch BranchUser[]
|
||||
branch BranchUser[]
|
||||
userMenuPermission UserMenuPermission[]
|
||||
userMenuComponentPermission UserMenuComponentPermission[]
|
||||
}
|
||||
|
||||
enum CustomerType {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue