Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prisma migration issue #2

Open
venkats-cr opened this issue Jul 19, 2024 · 7 comments
Open

prisma migration issue #2

venkats-cr opened this issue Jul 19, 2024 · 7 comments

Comments

@venkats-cr
Copy link

venkats-cr commented Jul 19, 2024

Unable to migrate the issue with prisma

Error: P3018

A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve

Migration name: 20240415100000_added_category_id_field_in_product_table

Database error code: 1146

Database error:
Table 'newEcommerce.product' doesn't exist

Please check the query number 1 from the migration file.

@Kuzma02
Copy link
Owner

Kuzma02 commented Jul 19, 2024

Hi @venkats-cr. Can you tell me more information about the error? Is this your first migration or have you run the project several times successfully before this? Also, did the error happen after your custom migration?

@venkats-cr
Copy link
Author

venkats-cr commented Jul 19, 2024 via email

@Kuzma02
Copy link
Owner

Kuzma02 commented Jul 19, 2024

I think you should watch the tutorial on running the project again and try to repeat the steps. The tutorial link is in the README. If you didn't see it, here is the link: https://www.youtube.com/watch?v=Ry0aOMws0gE

@Kuzma02
Copy link
Owner

Kuzma02 commented Jul 19, 2024

@venkats-cr When you find a solution to the problem, please feel free to post it here.

@venkats-cr
Copy link
Author

venkats-cr commented Jul 19, 2024 via email

@venkats-cr
Copy link
Author

venkats-cr commented Jul 19, 2024 via email

@Neutrino2019
Copy link

I had the same issue, and i was able to fix it. So here is the solution :

⚠The problem :

I use the latest mysql 9.1.0, and i also got the error :
Table 'newEcommerce.product' doesn't exist
▶ It's because previously, the product table was created with an uppercase first letter :
image
but later in the migration files, they use "product" without the first letter in uppercase :
image
⏩ So mysql table names are sensitive to case. And if you fix only "product", there will be other names to fix as they also have the upper case letter issue.

💡 The solution :

To fix this issue, i changed with a text editor all the table names's first letter to uppercase by editing the migration.sql (in your-project-directory\server\prisma\migrations\*\migration.sql) that is mentionned in the error. So Everytime, I run the command npx prisma migrate dev and fix the table name issue until there is no error. At the end the terminal proposed to reset the database, and i said "yes".
image

At the end you shoud get something like this :
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants