Closed pedropmedina closed 1 year ago
@pedropmedina thanks for the report. I made changes to how the imports are handled in one of the latest Versions so there ist obviously a bug somewhere. can you provide a Schema/config so I can reproduce the issue?
Hey @chrishoermann try this schema. The issue it's with join tables RoleToUser
and RolesToResourcesToActions
generator client {
provider = "prisma-client-js"
output = "../../../../../node_modules/@prisma/client/auth"
previewFeatures = ["fullTextSearch", "fullTextIndex"]
}
generator zod-prisma-types {
provider = "zod-prisma-types"
output = "./generated/zod"
prismaClientPath = "@prisma/client/auth"
useMultipleFiles = true
useDefaultValidators = false
}
datasource db {
provider = "mysql"
url = env("AUTH_DATABASE_URL")
}
model Application {
id String @id @default(cuid())
nameId String @unique @map("name_id")
name String
description String? @db.Text
url String?
resources Resource[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@map("applications")
}
model Action {
id String @id @default(cuid())
nameId String @unique @map("name_id")
name String
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
rolesToResources RolesToResourcesToActions[]
@@map("actions")
}
model Resource {
id String @id @default(cuid())
name String
description String? @db.Text
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
applicationId String @map("application_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
rolesToActions RolesToResourcesToActions[]
@@map("resources")
}
model Role {
id String @id @default(cuid())
nameId String @unique @map("name_id")
name String
isSuperAdmin Boolean? @default(false) @map("is_super_admin")
isAdmin Boolean? @default(false) @map("is_admin")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
resourcesToActions RolesToResourcesToActions[]
users RoleToUser[]
@@map("roles")
}
model RoleToUser {
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String @map("user_id")
role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)
roleId String @map("role_id")
@@id([userId, roleId])
@@map("roles_to_users")
}
model RolesToResourcesToActions {
roleId String
role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)
resourceId String
resource Resource @relation(fields: [resourceId], references: [id], onDelete: Cascade)
actionId String
action Action @relation(fields: [actionId], references: [id], onDelete: Cascade)
@@id([roleId, resourceId, actionId])
@@map("roles_to_resources_to_actions")
}
model Department {
id String @id @default(cuid())
nameId String @unique @map("name_id")
name String
description String? @db.Text
users User[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@map("departments")
}
model UserType {
id String @id @default(cuid())
nameId String @unique @map("name_id")
name String
description String? @db.Text
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
user User[] @relation("user_type")
@@map("user_types")
}
model User {
firstName String? @map("first_name")
lastName String? @map("last_name")
phone String?
isActive Boolean? @default(true) @map("is_active")
isEmployee Boolean? @default(false) @map("is_employee")
isCustomer Boolean? @default(false) @map("is_customer")
department Department? @relation(fields: [departmentId], references: [id])
departmentId String? @unique @map("department_id")
userType UserType? @relation(name: "user_type", fields: [userTypeId], references: [id])
userTypeId String? @unique @map("user_type_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
roles RoleToUser[]
id String @id @default(cuid())
email String @unique
@@map("users")
}
}
@pedropmedina this should now be fixed in the latest release.
Hi @chrishoermann. I'm having this issue with the recent version where not imports are generated for pivot tables and the schema itself is empty which kind of makes sense, but it's causing issue?