Home  >  Q&A  >  body text

Table `main.Product` does not exist in the current database. How to deploy Prisma database on render.com?

In the last part of my project, I can't seem to deploy the prisma database correctly. The site builds successfully and I can view the site, but when I try to access the database it shows the following:

Invalid prisma.product.findUnique() call: Table main.Product does not exist in the current database.

I do have the schema for migration:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}
...
model Product {
  id               String         @id@unique
  quantity         Int            @default(0)
  physical         Boolean        @default(false)
  onhold           Int            @default(0)
}

...

During the build process on render.com it specifies the following:

November 3 02:40:16 PM Import { PrismaClient } from "@prisma/client" November 3 02:40:16 PM const prisma = new PrismaClient() November 3, 02:40:16 pm

November 3, 02:40:19 PM Load Prisma schema from server/database/schema.prisma November 3, 02:40:19 PM Data source "db": SQLite database "dev.db" located at "file:./dev.db" November 3, 02:40:19 PM

Nov 3 02:40:19 PM No migrations found in prisma/migrations November 3, 02:40:19 PM

November 3, 02:40:19 PM

Nov 3 02:40:19 PM There are no pending transfers.

I have set up the build command:

npm installation; prisma generation--schema=./server/database/schema.prisma; prisma migration deployment--schema=./server/database/schema.prisma; npm run build;

There was no migration directory in the latest commit

When the project builds, will it contain what I configured for migration? Does "--schema=..." point to the correct directory when building?

What I tried: Overall, I have more problems than I've tried with things I've tried due to my lack of knowledge.

When I look at the nuxt build file for this project, it produces a completely different file structure than when it was not built, could it be pointing to an error when scaling the SQL database to dev.db?

Also, SQL lite is not suitable for production? If so, what alternative would be better and how to install this database on the deployment server?

11 月 3 日 02:40:19 PM 数据源“db”:SQLite 数据库“dev.db”位于“file:./dev.db”

Does this line indicate that it has found the database to connect to? Overall, I'm confused as to why it can't find the products table, even though it's provided in my schema.

The overall question is, what causes a built nuxt application to not see this table when querying?

P粉151720173P粉151720173303 days ago477

reply all(1)I'll reply

  • P粉186904731

    P粉1869047312023-12-22 12:37:54

    OP solved the issue by running the migration before linking to the schema.

    reply
    0
  • Cancelreply