databasedatabase-schemaprismaplanetscalet3

Why can't npx prisma db push find my prisma schema?


I'm trying to setup my first t3 app and I have no idea how prisma works. Trying to set up my database following a tutorial and I cannot get my prisma schema to push. I follow the tutorial precisely and it still doesn't work.

Command:

$npx prisma db push

Error:

Error: 'could not find a schema.prisma file that is required for this command'...but my prisma file exists.

Code:

Database is created on planetscale. Directory setup using create-t3-app.

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"
    previewFeatures = ['referentialIntegrity']
}

datasource db {
    provider = "mysql"
    url      = env("DATABASE_URL")
    referentialIntegrity = "prisma"
}

model Example {
    id        String   @id @default(cuid())
    name String
    checked Boolean
}

.env

# When adding additional environment variables, the schema in "/src/env.mjs"
# should be updated accordingly.

# Prisma
# https://www.prisma.io/docs/reference/database-reference/connection-urls#env
DATABASE_URL=mysql://mekxxh8g4nqmo6262jnc:**********@us-east.connect.psdb.cloud/mikes-first-crappy-db?sslaccept=strict

package.json:

"prisma": {
    "schema": "./prisma/schema.prisma"
  }

Solutions I have tried and have not worked:

This site recommends updating the json. I have tried this but I still cannot push my schema. I have also tried wrapping my DATABASE_URL in double, single, and no quotes. I have installed the prisma@4.10.1 package. None of these have worked for me. Just not sure what I could be doing wrong.


Solution

  • I would recommend you to pass the schema file location while invoking npx prisma db push command.

    npx prisma db push --schema='/location/to/schema.prisma'
    

    Also, I would recommend you to run the command from root location of your project.

    Here's a reference for db push command.