hellvisor
hellvisor

Reputation: 538

The underlying table for model 'Order' does not exist. Error code: P1014 (Prisma)

I have such problem as below

$ prisma migrate dev --name "ok"
    
Error: P3006
    
Migration `2021080415559_order_linking` failed to apply clearnly to the shadow database.
Error code: P1014
Error:
The underlying table for model 'Order' does not exist.

How to fix it?

Upvotes: 4

Views: 8516

Answers (2)

Tasin Ishmam
Tasin Ishmam

Reputation: 7238

It looks like your migrations were corrupted somehow. There was probably changes to your database that was not recorded in the migration history.

You could try one of these:

  • If you're okay with losing the data in the database, try resetting the database with prisma migrate reset. More info
  • Try running introspection to capture any changes to the database with prisma introspect before applying a new migration. More info

Upvotes: 3

hellvisor
hellvisor

Reputation: 538

The solution:

It seems that this may be due to the migration file in the prisma folder. I decided to delete the Migration Files and the whole folder with it. I restarted the application, it got a new file and it worked.

*delete the migrations folder*

$ prisma generate

$ prisma migrate dev --name "ok"

*it works*

Upvotes: 5

Related Questions