refactor:替换自增id为cuid
This commit is contained in:
@@ -13,17 +13,17 @@ datasource db {
|
||||
|
||||
// 系统用户表
|
||||
model SysUser {
|
||||
id Int @id @default(autoincrement()) /// 主键id
|
||||
id String @id @default(cuid()) /// 主键id
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
updatedAt DateTime @updatedAt @map("updated_at") /// 修改时间
|
||||
name String? /// 用户姓名
|
||||
account String @unique /// 账户
|
||||
password String /// 密码
|
||||
passwordSalt String @map("password_salt") /// 密码盐
|
||||
status Int @default(0) @db.SmallInt /// 用户状态
|
||||
avatarId Int? @map("avatar_id") /// 用户头像id
|
||||
avatar Files? @relation(fields: [avatarId], references: [id])
|
||||
avatarId String? @map("avatar_id") /// 用户头像id
|
||||
avatar File? @relation(fields: [avatarId], references: [id])
|
||||
gender Int @default(0) @db.SmallInt /// 用户性别 0:女 1:男 2:未知
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
updatedAt DateTime @updatedAt @map("updated_at") /// 修改时间
|
||||
userRole SysUserRole[]
|
||||
|
||||
@@index([avatarId])
|
||||
@@ -32,7 +32,9 @@ model SysUser {
|
||||
|
||||
// 系统角色表
|
||||
model SysRole {
|
||||
id Int @id @default(autoincrement())
|
||||
id String @id @default(cuid()) /// 主键id
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
updatedAt DateTime @updatedAt @map("updated_at") /// 修改时间
|
||||
code String @unique
|
||||
name String
|
||||
status Int @default(0) @db.SmallInt /// 角色状态
|
||||
@@ -44,11 +46,13 @@ model SysRole {
|
||||
|
||||
// 用户角色关联表
|
||||
model SysUserRole {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int @map("user_id")
|
||||
roleId Int @map("role_id")
|
||||
user SysUser @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
role SysRole @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
||||
id String @id @default(cuid()) /// 主键id
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
updatedAt DateTime @updatedAt @map("updated_at") /// 修改时间
|
||||
userId String @map("user_id")
|
||||
roleId String @map("role_id")
|
||||
user SysUser @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
role SysRole @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@index([roleId])
|
||||
@@ -56,19 +60,22 @@ model SysUserRole {
|
||||
}
|
||||
|
||||
// 文件表
|
||||
model Files {
|
||||
id Int @id @default(autoincrement())
|
||||
model File {
|
||||
id String @id @default(cuid()) /// 主键id
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
updatedAt DateTime @updatedAt @map("updated_at") /// 修改时间
|
||||
name String /// 文件名称
|
||||
path String
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
sysUser SysUser[]
|
||||
|
||||
@@map("files")
|
||||
@@map("file")
|
||||
}
|
||||
|
||||
// 权限表
|
||||
model SysPermission {
|
||||
id Int @id @default(autoincrement())
|
||||
id String @id @default(cuid()) /// 主键id
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
updatedAt DateTime @updatedAt @map("updated_at") /// 修改时间
|
||||
type Int
|
||||
sysRolePermission SysRolePermission[]
|
||||
sysMenuPermission SysMenuPermission[]
|
||||
@@ -78,10 +85,12 @@ model SysPermission {
|
||||
|
||||
// 系统菜单表
|
||||
model SysMenu {
|
||||
id Int @id @default(autoincrement())
|
||||
id String @id @default(cuid()) /// 主键id
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
updatedAt DateTime @updatedAt @map("updated_at") /// 修改时间
|
||||
name String
|
||||
url String
|
||||
parentId Int @default(0) @map("parent_id")
|
||||
parentId String? @map("parent_id")
|
||||
sort Int @default(0)
|
||||
sysMenuPermission SysMenuPermission[]
|
||||
|
||||
@@ -90,9 +99,11 @@ model SysMenu {
|
||||
|
||||
// 菜单权限关联表
|
||||
model SysMenuPermission {
|
||||
id Int @id @default(autoincrement())
|
||||
menuId Int @map("menu_id")
|
||||
permissionId Int @map("permission_id")
|
||||
id String @id @default(cuid()) /// 主键id
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
updatedAt DateTime @updatedAt @map("updated_at") /// 修改时间
|
||||
menuId String @map("menu_id")
|
||||
permissionId String @map("permission_id")
|
||||
menu SysMenu @relation(fields: [menuId], references: [id], onDelete: Cascade)
|
||||
permission SysPermission @relation(fields: [permissionId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@ -103,9 +114,11 @@ model SysMenuPermission {
|
||||
|
||||
// 角色权限关联表
|
||||
model SysRolePermission {
|
||||
id Int @id @default(autoincrement())
|
||||
roleId Int @map("role_id")
|
||||
permissionId Int @map("permission_id")
|
||||
id String @id @default(cuid()) /// 主键id
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
updatedAt DateTime @updatedAt @map("updated_at") /// 修改时间
|
||||
roleId String @map("role_id")
|
||||
permissionId String @map("permission_id")
|
||||
role SysRole @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
||||
permission SysPermission @relation(fields: [permissionId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@ -116,9 +129,12 @@ model SysRolePermission {
|
||||
|
||||
// 系统配置
|
||||
model SysConfig {
|
||||
key String @unique
|
||||
value String
|
||||
remark String?
|
||||
id String @id @default(cuid()) /// 主键id
|
||||
createdAt DateTime @default(now()) @map("created_at") /// 创建时间
|
||||
updatedAt DateTime @updatedAt @map("updated_at") /// 修改时间
|
||||
key String @unique
|
||||
value String
|
||||
remark String?
|
||||
|
||||
@@map("sys_config")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user