2
0

feat(db): 🗃️ Add createdAt and updatedAt

This commit is contained in:
Baptiste Arnaud
2022-02-24 14:52:35 +01:00
parent b9dafa611e
commit a499d85c98
6 changed files with 54 additions and 18 deletions

View File

@ -0,0 +1,13 @@
-- AlterTable
ALTER TABLE "Credentials" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "CustomDomain" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "Invitation" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "User" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "lastActivityAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

View File

@ -39,6 +39,9 @@ model Session {
model User {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
lastActivityAt DateTime @default(now())
name String?
email String? @unique
emailVerified DateTime?
@ -56,19 +59,21 @@ model User {
}
model CustomDomain {
ownerId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
name String @unique
createdAt DateTime @default(now())
ownerId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
name String @unique
}
model Credentials {
id String @id @default(cuid())
ownerId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
data String // Encrypted data
name String
type String
iv String
id String @id @default(cuid())
createdAt DateTime @default(now())
ownerId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
data String // Encrypted data
name String
type String
iv String
@@unique([name, type, ownerId])
}
@ -129,6 +134,7 @@ model Typebot {
}
model Invitation {
createdAt DateTime @default(now())
email String
typebotId String
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)