skip to Main Content

I have created Postgres database with Vercel, and when trying to migrate with command npx prisma migrate dev i receive:

Environment variables loaded from .env
Prisma schema loaded from prismaschema.prisma       
Datasource "db": PostgreSQL database "verceldb", schema "public" at "ep-curly-resonance-50034155.eu-central-1.postgres.vercel-storage.com:5432"

Error: Schema engine error:
ERROR: password authentication failed for user ''

I’m weak in the backend and don’t know how to help you understand the problem, so I’m leaving these prisma and .env codes in case you need them:

schema.prisma:

// 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("POSTGRES_PRISMA_URL") // uses connection pooling
  directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
}

model Form {
  id Int @id @default(autoincrement())
  userId String
  createdAt DateTime @default(now())
  published Boolean @default(false)
  name String
  description String @default("")
  content String @default("[]")

  visits Int @default(0)
  submissions Int @default(0)

  shareURL String @default(uuid())
  FormSubmissions FormSubmissions[]
}

model FormSubmissions {
  id Int @id @default(autoincrement())
  createdAt DateTime @default(now())
  formId Int
  form Form @relation(fields: [formId], references: [id])

  content String
}

.env:

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_aW1tZW5zZS1mYWxjb24tNzQuY2xlcmsuYWNjb3VudHMuZGV2JA
CLERK_SECRET_KEY=sk_test_w9Pc0w9eCvYrcl4iwogc28r2YLPbIyhKyZRAi8Sw7A

NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/

# This was inserted by `prisma init`:
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

POSTGRES_PRISMA_URL="postgres://:@ep-curly-resonance-50034155-pooler.eu-central-1.postgres.vercel-storage.com:5432/verceldb?pgbouncer=true&connect_timeout=15"
POSTGRES_URL_NON_POOLING="postgres://:@ep-curly-resonance-50034155.eu-central-1.postgres.vercel-storage.com:5432/verceldb"

2

Answers


  1. You dont have any user name and password in your .env file for posgresql db.

    A connection URL can also take arguments. Here is the same example from above with placeholder values in uppercase letters for three arguments:

    postgresql://USER:PASSWORD@HOST:PORT/DATABASE?KEY1=VALUE&KEY2=VALUE&KEY3=VALUE

    If you create your db on Versel, you need to find in tab ".env.local" env-variables named: "POSTGRES_USER" and "POSTGRES_PASSWORD" or just copy all of them and paste in your .env file.

    Login or Signup to reply.
  2. Don’t put the variable names here, put the actual values of that variables

    POSTGRES_PRISMA_URL="postgres://POSTGRES_USER:POSTGRES_PASSWORD@ep-curly-resonance-50034155-pooler.eu-central-1.postgres.vercel-storage.com:5432/verceldb?pgbouncer=true&connect_timeout=15"

    POSTGRES_URL_NON_POOLING="postgres://POSTGRES_USER:POSTGRES_PASSWORD@ep-curly-resonance-50034155.eu-central-1.postgres.vercel-storage.com:5432/verceldb"

    env snippet

    The values of POSTGRES_USER and POSTGRES_PASSWORD would be available in the snippet! You can view it in the link above!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search