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

Gracefully handle MongoDB migration #11

Open
KyleSmith0905 opened this issue Jun 19, 2024 · 3 comments
Open

Gracefully handle MongoDB migration #11

KyleSmith0905 opened this issue Jun 19, 2024 · 3 comments
Assignees

Comments

@KyleSmith0905
Copy link

KyleSmith0905 commented Jun 19, 2024

Description

When selecting yes on "Do you want to migrate database changes to your database?" my CLI would spit out an error.
(edit: I read the message of course, but it probably should not give an error if I was prompted to do something).

Idk if this is a bigger error but right after I get a message saying "Failed to install Prisma Client", I assume they're linked.

Reproduction

https://github.com/KyleSmith0905/mre--prisma-nuxt

Or create a new Nuxt project with "pnpm dlx nuxi@latest init " and add prisma's packages and modules to it

CLI

√ Do you want to migrate database changes to your database? ... yes
Migrating database schema...                                                                                                                                                                        7:20:57 PM  


 ERROR  ✘ Failed to run Prisma migration.                                                                                                                                                           7:20:58 PM  

Command failed with exit code 1: npx prisma migrate dev --name init                                                                                                                                 7:20:58 PM  
Error: The "mongodb" provider is not supported with this command. For more info see https://www.prisma.io/docs/concepts/database-connectors/mongodb
   0: schema_core::state::DevDiagnostic
             at schema-engine\core\src\state.rs:276

Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": MongoDB database "db" at "cluster.nzjgwap.mongodb.net"


  Error: The "mongodb" provider is not supported with this command. For more info see https://www.prisma.io/docs/concepts/database-connectors/mongodb
  0: schema_core::state::DevDiagnostic
  at schema-engine\core\src\state.rs:276

  Environment variables loaded from .env
  Prisma schema loaded from prisma\schema.prisma
  Datasource "db": MongoDB database "db" at "cluster.nzjgwap.mongodb.net"

  at makeError (/C:/Users/ceohi/OneDrive/Documents/projects/mre--prisma-nuxt/node_modules/.pnpm/[email protected]/node_modules/execa/lib/error.js:60:11)
  at handlePromise (/C:/Users/ceohi/OneDrive/Documents/projects/mre--prisma-nuxt/node_modules/.pnpm/[email protected]/node_modules/execa/index.js:124:26)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async runMigration (/C:/Users/ceohi/OneDrive/Documents/projects/mre--prisma-nuxt/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@prisma/nuxt/dist/module.mjs:235:5)
  at async migrateAndFormatSchema (/C:/Users/ceohi/OneDrive/Documents/projects/mre--prisma-nuxt/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@prisma/nuxt/dist/module.mjs:406:9)
  at async prismaMigrateWorkflow (/C:/Users/ceohi/OneDrive/Documents/projects/mre--prisma-nuxt/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@prisma/nuxt/dist/module.mjs:421:9)
  at async setup (/C:/Users/ceohi/OneDrive/Documents/projects/mre--prisma-nuxt/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@prisma/nuxt/dist/module.mjs:469:7)     
  at async normalizedModule (/C:/Users/ceohi/OneDrive/Documents/projects/mre--prisma-nuxt/node_modules/.pnpm/@[email protected][email protected]/node_modules/@nuxt/kit/dist/index.mjs:2127:17)
  at async installModule (/C:/Users/ceohi/OneDrive/Documents/projects/mre--prisma-nuxt/node_modules/.pnpm/@[email protected][email protected]/node_modules/@nuxt/kit/dist/index.mjs:2469:95)
  at async initNuxt (/C:/Users/ceohi/OneDrive/Documents/projects/mre--prisma-nuxt/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/nuxt/dist/index.mjs:4395:5)
                                                                                                                                                                                                    7:20:58 PM  
Hint: You can manually run migrations by executing npx prisma migrate dev or visit the Prisma Migrate docs for more info:
https://pris.ly/nuxt/migrate. Or if you have pre-existing data on your database, you have to introspect it. Learn more in our docs:
https://pris.ly/nuxt/dbpull.

Formatting Prisma schema...                                                                                                                                                                         7:20:58 PM  

Generating Prisma client...                                                                                                                                                                         7:21:00 PM


 ERROR  ✘ Failed to install Prisma Client.                                                                                                                                                          7:21:14 PM  


                                                                                                                                                                                                    7:21:16 PM
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
@ankur-arch
Copy link
Contributor

Hey there @KyleSmith0905 👋, thanks for reproducing the issue 😄!

(edit: I read the message of course, but it probably should not give an error if I was prompted to do something)

Migration prompts can sometimes fail. If they do, we provide steps to handle the error. Could you let me know what you were expecting to happen?

ERROR ✘ Failed to install Prisma Client.

This error seems to occur when using pnpm, but the module should work as expected. The error disappears when I run pnpm i @prisma/client.

I'll look into this further.

@ankur-arch ankur-arch self-assigned this Jun 20, 2024
@KyleSmith0905
Copy link
Author

I would expect either one of these two:

  1. Not prompt of migration if it's not possible.
  2. Handle the CLI output gracefully by printing "MongoDB provider couldn't be migrated" instead of the errorz

You'll probably have better intuition, on what reads the best. 👍

Despite seeing why the error was caused, I had inferred something else was wrong (since I got a whole stack trace).

@ankur-arch
Copy link
Contributor

Thanks again for elaborating!

We'll possibly keep the verbose log turned off by default and add a key in the config to enable it for further debugging.

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

2 participants