The table `(not available)` does not exist in the current database

See original GitHub issue

Bug description

I’m getting this error with a PlanetScale database

Message: Error in Prisma Client request: 

{"type":"PrismaClientKnownRequestError","code":"P2021","message":"\nInvalid `prisma.counters.findMany()` invocation:\n\n\n  The table `(not available)` does not exist in the current database.","stack":"Error: \nInvalid `prisma.counters.findMany()` invocation:\n\n\n  The table `(not available)` does not exist in the current database.\n    at cb (/var/task/node_modules/@prisma/client/runtime/index.js:38683:17)\n    at async /var/task/node_modules/@prisma/studio-pcw/dist/index.js:391:34\n    at async /var/task/node_modules/@prisma/studio-pcw/dist/index.js:375:28\n    at async eval (eval at request (/var/task/node_modules/@prisma/studio-pcw/dist/index.js:408:52), <anonymous>:3:8)\n    at async $25632e7ad2eabd1d$var$PCW.request (/var/task/node_modules/@prisma/studio-pcw/dist/index.js:408:46)\n    at async /var/task/.next/server/pages/api/databrowser.js:767:28\n    at async /var/task/.next/server/pages/api/databrowser.js:759:41\n    at async /var/task/.next/server/pages/api/graphql.js:10924:7\n    at async /var/task/.next/server/pages/api/graphql.js:10924:7\n    at async handlerTraceWrapperSpan (/var/task/.next/server/pages/api/graphql.js:11268:22)"}
  
Query:
prisma.counters.findMany({
  take: 100,
  skip: 0,
  select: {
    slug: true,
    views: true,
    likes: true,
    loves: true,
    awards: true,
    bookmarks: true,
  }
})

How to reproduce

I’m not sure, but I have this setup in my repo jahirfiquitiva/jahir.dev@dev

Expected behavior

No response

Prisma information

Environment & setup

  • OS: macOS
  • Database: PlanetScale MySQL
  • Node.js version: 14.17.4

Prisma Version

3.6.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

26reactions
janpiocommented, Dec 20, 2021

Tables usually have to exist first before you can use them via Prisma. You can use npx prisma db push for PlanetScale for example on a new branch, then merge that via a deploy request into your production branch.

4reactions
prkagrawalcommented, Mar 12, 2022

So, whenever we update schema.prisma file, we need to either use db-push (for testing) or prisma-migrate (for prod) to sync prisma schema with our database schema.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The underlying table for model 'Order' does not exist. Error code
It seems that this may be due to the migration file in the prisma folder. I decided to delete the Migration Files and...
Read more >
Table does not exist in the current database - Fly.io
Using flyctl postgres connect , I list the tables and test a selection on the Group table, with no success… But the table...
Read more >
Problem with model and existing db - Get Help and Help Others
The table `gvg.Source` does not exist in the current database. when it is accessible via prisma studio.
Read more >
Documentation: 15: CREATE TABLE - PostgreSQL
A data row inserted into the table is routed to a partition based on the value of columns or expressions in the partition...
Read more >
CREATE TABLE reference | QuestDB: the database for time ...
An optional IF NOT EXISTS clause may be added directly after the CREATE TABLE keywords to indicate that a new table should be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found