0

I am trying to connect/migrate my Prisma schema into my MongoDB cluster. I have my MongoDB connection string, and have an instance of the Prisma client.

Here is my prisma/schema.prisma file:

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

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

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}


model User {
  id        String    @id @default(auto()) @map("_id") @db.ObjectId
  createdAt DateTime  @default(now())
  username  String
  password  String 
  email     String    @unique
}

So, in order to migrate, I used the command "npx prisma migrate dev" and got this error:

Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma Datasource "db": MongoDB database "DATABASE" at "HOST"

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:266

I went to that link in the Prisma docs, and and saw this: "Currently, there are no plans to add support for Prisma Migrate as MongoDB projects do not rely on internal schemas where changes need to be managed with an extra tool. Management of @unique indexes is realized through db push."

So, I tried the command "npx db push", and got this error: npm ERR! could not determine executable to run

So, how do I fix it and do a correct migration? And if there are differences between development and production environment migrations, what are those differences?

Thanks

1 Answer 1

0

Yes you cannot use npx prisma migrate dev because the the mongodb adapter doesn't need's it.

npx db push Should work, and the error you are getting, npm ERR! could not determine executable to run is unrelated to mongodb, check if prisma installed correctly.

For the development and production environments, you can manually create migration scripts using prisma.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.