Skip to content

Commit

Permalink
feat(prisma): 新增 Menu 模型
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwumm committed Jan 15, 2025
1 parent 1b7d593 commit 2bd2521
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
29 changes: 29 additions & 0 deletions prisma/migrations/20250113093120_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- CreateTable
CREATE TABLE "Menu" (
"id" TEXT NOT NULL,
"parentId" TEXT,
"name" TEXT NOT NULL,
"path" TEXT NOT NULL,
"icon" TEXT NOT NULL,
"redirect" TEXT,
"sort" INTEGER NOT NULL DEFAULT 1,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Menu_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Menu_name_key" ON "Menu"("name");

-- CreateIndex
CREATE UNIQUE INDEX "Menu_path_key" ON "Menu"("path");

-- CreateIndex
CREATE UNIQUE INDEX "Menu_icon_key" ON "Menu"("icon");

-- CreateIndex
CREATE UNIQUE INDEX "Menu_redirect_key" ON "Menu"("redirect");

-- AddForeignKey
ALTER TABLE "Menu" ADD CONSTRAINT "Menu_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Menu"("id") ON DELETE SET NULL ON UPDATE CASCADE;
5 changes: 5 additions & 0 deletions prisma/migrations/20250114012733_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DropIndex
DROP INDEX "Menu_icon_key";

-- DropIndex
DROP INDEX "Menu_redirect_key";
15 changes: 15 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,18 @@ model Authenticator {
@@id([userId, credentialID])
}

// 系统管理 - 菜单管理
model Menu {
id String @id @default(uuid()) // 主键
parentId String?
parent Menu? @relation(name: "MenuHierarchy", fields: [parentId], references: [id])
name String @unique // 路由名称
path String @unique // 路由地址
icon String // 菜单图标
redirect String? // 重定向地址
sort Int @default(1)// 排序
createdAt DateTime @default(now()) // 创建时间
updatedAt DateTime @updatedAt // 更新时间
children Menu[] @relation(name: "MenuHierarchy")
}

0 comments on commit 2bd2521

Please sign in to comment.