Try signing in with a different account.

I just got setup with my first t3 app ever, sorry if I'm a noob. I've created two different discord apps for auth. The one I have in my dev environment works perfectly and I'm able to sign in. I've got the environment variables and redirect url setup correctly. I also have a deployed production one which is hosted on vercel (https://t3-scouter.vercel.app/). I set it up the exact same way, setup the new environment variables, and the new redirect URL as: https://t3-scouter.vercel.app/api/auth/callback/discord instead of localhost:3000/. And I get this error. I tried switching from sqlite to mysql on planetscale (like the tutorial), and it all seems ot be working locally, but for some reason the deployed one doesn't work. My DATABASE_URL is the same in my dev and prod environments right now since I'm just trying to get it to work, and then I'll go and create a second prod db over at planetscale.
prisma:error
Invalid `prisma.account.findUnique()` invocation:


error: Error validating datasource `db`: the URL must start with the protocol `file:`.
--> schema.prisma:14
|
13 | // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
14 | url = env("DATABASE_URL")
|

Validation Error Count: 1
[next-auth][error][adapter_error_getUserByAccount]
https://next-auth.js.org/errors#adapter_error_getuserbyaccount
Invalid `prisma.account.findUnique()` invocation:


error: Error validating datasource `db`: the URL must start with the protocol `file:`.
--> schema.prisma:14
|
13 | // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
14 | url = env("DATABASE_URL")
|

there's more but i hit my character limit on this question...
}
prisma:error
Invalid `prisma.account.findUnique()` invocation:


error: Error validating datasource `db`: the URL must start with the protocol `file:`.
--> schema.prisma:14
|
13 | // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
14 | url = env("DATABASE_URL")
|

Validation Error Count: 1
[next-auth][error][adapter_error_getUserByAccount]
https://next-auth.js.org/errors#adapter_error_getuserbyaccount
Invalid `prisma.account.findUnique()` invocation:


error: Error validating datasource `db`: the URL must start with the protocol `file:`.
--> schema.prisma:14
|
13 | // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
14 | url = env("DATABASE_URL")
|

there's more but i hit my character limit on this question...
}
No description
Solution:
id_token String? // @db.Text
Jump to solution
11 Replies
plaZma
plaZma9mo ago
This is my schema as well.
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "mysql"
// NOTE: When using 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")
relationMode = "prisma"
}

model Post {
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

createdBy User @relation(fields: [createdById], references: [id])
createdById String

@@index([name])
}

// 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)

@@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)
}

model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
posts Post[]
}

model VerificationToken {
identifier String
token String @unique
expires DateTime

@@unique([identifier, token])
}
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "mysql"
// NOTE: When using 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")
relationMode = "prisma"
}

model Post {
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

createdBy User @relation(fields: [createdById], references: [id])
createdById String

@@index([name])
}

// 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)

@@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)
}

model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
posts Post[]
}

model VerificationToken {
identifier String
token String @unique
expires DateTime

@@unique([identifier, token])
}
ElonMask
ElonMask9mo ago
share gh
plaZma
plaZma9mo ago
sorry what's gh? im a total noob D: oh shoot. i may have just fixed it
ElonMask
ElonMask9mo ago
github * aah nice : )
plaZma
plaZma9mo ago
i literally just commented out one thing and pushed it and now it works
ElonMask
ElonMask9mo ago
lolol
Solution
plaZma
plaZma9mo ago
id_token String? // @db.Text
ElonMask
ElonMask9mo ago
ah
plaZma
plaZma9mo ago
i was browsing other people's posts abt this problem and one person had their schema and it was commented out instead of uncommented so now my schema is:
// 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)

@@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)
}

model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
posts Post[]
}

model VerificationToken {
identifier String
token String @unique
expires DateTime

@@unique([identifier, token])
}
// 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)

@@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)
}

model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
posts Post[]
}

model VerificationToken {
identifier String
token String @unique
expires DateTime

@@unique([identifier, token])
}
and it works no clue why that was the fix - i dont really know what im doing here what's really strange is it was working in my dev environment even when that wasnt commented out
plaZma
plaZma9mo ago
Oh well. This might cause issues later but we'll see. Thanks for the help ig
𝖋𝖔𝖈𝖚𝖘
For me, it was returning this Error from Prisma:
The table `main.Session` does not exist in the current database.
The table `main.Session` does not exist in the current database.
It seems that the Session model is defined in your Prisma schema but the corresponding table has not been created in your SQLite database. To resolve this issue, you can follow these steps: 1. Run Migrations: Ensure that your database schema is up to date with your Prisma schema. You can do this by running the following command:
npx prisma migrate dev --name init
npx prisma migrate dev --name init
This command will create the necessary tables in your database based on your Prisma schema. 2. Push Schema Changes: If you are not using migrations and just want to push the current schema to the database, you can use:
npx prisma db push
npx prisma db push
3. Check Database Connection: Ensure that your DATABASE_URL in the .env file is correctly pointing to your SQLite database. 4. Prisma Studio: You can also use Prisma Studio to visually inspect your database and confirm that the Session table has been created:
npx prisma studio
npx prisma studio
After performing these steps, the Session table should exist in your database, and the error should be resolved.
Want results from more Discord servers?
Add your server