From 112272083e6130209bfbac0cd350e985dcd9f19f Mon Sep 17 00:00:00 2001 From: Shoubhit Dash Date: Tue, 18 Oct 2022 09:05:48 +0530 Subject: [PATCH] feat(template): add createdAt and updatedAt to example model (#619) * feat(template): add createdAt and updatedAt to example model * Create hot-stingrays-live.md * chore: format * chore: run npx prisma format again Co-authored-by: Christopher Ehrlich --- .changeset/hot-stingrays-live.md | 5 ++ cli/template/addons/prisma/auth-schema.prisma | 78 ++++++++++--------- cli/template/addons/prisma/schema.prisma | 10 ++- 3 files changed, 51 insertions(+), 42 deletions(-) create mode 100644 .changeset/hot-stingrays-live.md diff --git a/.changeset/hot-stingrays-live.md b/.changeset/hot-stingrays-live.md new file mode 100644 index 0000000000..293101d7f7 --- /dev/null +++ b/.changeset/hot-stingrays-live.md @@ -0,0 +1,5 @@ +--- +"create-t3-app": patch +--- + +Added `createdAt` and `updatedAt` fields to the Example model in the Prisma schema. diff --git a/cli/template/addons/prisma/auth-schema.prisma b/cli/template/addons/prisma/auth-schema.prisma index 3184c21dc7..1ac91dd455 100644 --- a/cli/template/addons/prisma/auth-schema.prisma +++ b/cli/template/addons/prisma/auth-schema.prisma @@ -2,63 +2,65 @@ // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" } datasource db { - provider = "sqlite" - // NOTE: When using postgresql, mysql or sqlserver, uncomment the @db.Text annotations in model Account below - // Further reading: - // https://next-auth.js.org/adapters/prisma#create-the-prisma-schema - // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string - url = env("DATABASE_URL") + provider = "sqlite" + // NOTE: When using postgresql, mysql or sqlserver, uncomment the @db.Text annotations in model Account below + // Further reading: + // https://next-auth.js.org/adapters/prisma#create-the-prisma-schema + // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string + url = env("DATABASE_URL") } model Example { - id String @id @default(cuid()) + id String @id @default(cuid()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt } // Necessary for Next auth model Account { - id String @id @default(cuid()) - userId String - type String - provider String - providerAccountId String - refresh_token String? // @db.Text - access_token String? // @db.Text - expires_at Int? - token_type String? - scope String? - id_token String? // @db.Text - session_state String? - user User @relation(fields: [userId], references: [id], onDelete: Cascade) + id String @id @default(cuid()) + userId String + type String + provider String + providerAccountId String + refresh_token String? // @db.Text + access_token String? // @db.Text + expires_at Int? + token_type String? + scope String? + id_token String? // @db.Text + session_state String? + user User @relation(fields: [userId], references: [id], onDelete: Cascade) - @@unique([provider, providerAccountId]) + @@unique([provider, providerAccountId]) } model Session { - id String @id @default(cuid()) - sessionToken String @unique - userId String - expires DateTime - user User @relation(fields: [userId], references: [id], onDelete: Cascade) + id String @id @default(cuid()) + sessionToken String @unique + userId String + expires DateTime + user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model User { - id String @id @default(cuid()) - name String? - email String? @unique - emailVerified DateTime? - image String? - accounts Account[] - sessions Session[] + id String @id @default(cuid()) + name String? + email String? @unique + emailVerified DateTime? + image String? + accounts Account[] + sessions Session[] } model VerificationToken { - identifier String - token String @unique - expires DateTime + identifier String + token String @unique + expires DateTime - @@unique([identifier, token]) + @@unique([identifier, token]) } diff --git a/cli/template/addons/prisma/schema.prisma b/cli/template/addons/prisma/schema.prisma index 34ba4eb7d5..06dc8cd1c9 100644 --- a/cli/template/addons/prisma/schema.prisma +++ b/cli/template/addons/prisma/schema.prisma @@ -2,14 +2,16 @@ // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" } datasource db { - provider = "sqlite" - url = env("DATABASE_URL") + provider = "sqlite" + url = env("DATABASE_URL") } model Example { - id String @id @default(cuid()) + id String @id @default(cuid()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt }