auth/prisma/schema.prisma

39 lines
834 B
Plaintext
Raw Normal View History

2022-12-16 15:46:14 +00:00
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Auth {
2023-07-04 10:16:34 +00:00
uuid String @id @default(uuid()) @db.Uuid
2022-12-16 15:46:14 +00:00
password String
2023-07-04 10:16:34 +00:00
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
usernames Username[]
2022-12-16 15:46:14 +00:00
@@map("auth")
}
2022-12-20 16:37:59 +00:00
model Username {
username String @id
2023-07-04 10:16:34 +00:00
authUuid String @db.Uuid
2022-12-20 16:37:59 +00:00
type Type @default(EMAIL) // type is needed in case of username update
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
2023-07-04 10:16:34 +00:00
Auth Auth @relation(fields: [authUuid], references: [uuid], onDelete: Cascade)
2022-12-20 16:37:59 +00:00
2023-07-04 10:16:34 +00:00
@@unique([authUuid, type])
2022-12-20 16:37:59 +00:00
@@map("username")
}
enum Type {
EMAIL
PHONE
}