Redwood: prisma2 schema binarytargets for windows

Created on 16 Mar 2020  ·  12Comments  ·  Source: redwoodjs/redwood

I have followed the tutorial and could try upto 'layouts'. But got struck in 'Getting dynamic' (https://redwoodjs.com/tutorial/getting-dynamic).

'yarn rw db up' is not completing. 'Prisma2 generate' command always hangs.

After some debug I found the problem to be in not specifying the 'binarytargets' for windows in prism schema file. I removed the binarytargets line in /api/prisma/schema.prisma, I ran the command 'yarn rw db up', the database migration commit succeeded.

bu0-needs-info kinbug

All 12 comments

Hi @balaji-balu Sorry you ran into some problems and appreciate you opening this Issue.

Just to confirm, there were no Error messages to report, correct? If there was any other helpful output you used to debug, could you please pass it along here?

And could you also include your schema.prisma file with edits you made to get yarn rw db up working?

No error message.
When I ran yarn rw db up , it was hanging indefinitely. I tried the query Posts in graphql Playground. I got errors. Then I realized the db up command is not working.
I was checking the prisma 2 docs

This is my working schema.prism file

// api/prisma/schema.prisma

datasource DS {
  provider = "sqlite"
  url = env("DATABASE_URL")
}

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

model Post {
  id        Int @id @default(autoincrement())
  title     String
  body      String
  createdAt DateTime @default(now())
}

model Contact {
  id        Int @id @default(autoincrement())
  name      String
  email     String
  message   String
  createdAt DateTime @default(now())
}

Please suggest appropriate solution to this issue

@balaji-balu Try running the command with tracing. That might provide you with a better error message

On windows cmd you can enable tracing by setting set DEBUG=*. If you are using something like Git Bash, you can enable it by using export DEBUG=*. After running this, rerun your original command

That can help in identifying the problem here.

@balaji-balu Try running in the terminal sqlite3 --version

What is the output?

If you getting something like _”command is not found”_ try running

C:\> choco install sqlite

Try running in the terminal sqlite3 --version

That should not matter as sqlite driver is managed by Prisma. Prisma ships a complete sqlite driver in the rust binaries.

@thedavidprice @cannikin Maybe a short term solution is to remove the binary targets line in the prisma configuration, and then suggest that people change it to binaryTargets = ["native", "rhel-openssl-1.0.x"] when they want to deploy to Netlify?

@peterp @cannikin Opening a new issue for this.

@peterp yeah we could do that and just add a step in the Tutorial when it's time for deployment.

Closing this issue given that we’ve diagnosed issue and working on implementation. See #278

Thanks for the help, everyone!

I am having a similar issue during the 'yarn rw db save' step of the tutorial. The 'dev.db' file gets created but the command hangs with 'You are trying to create a migration for Sqlite database /dev.db.'

$ C:\Users\AMaline\workspace\redwoodblog\node_modules\.bin\redwood db save
Creating database migration... [started]
$ C:\Users\AMaline\workspace\redwoodblog\node_modules\.bin\prisma2 migrate save --experimental
  prisma .env not loaded +0ms
  engineCommands getConfig, override prismaPath = undefined +0ms
  getos { platform: 'win32', libssl: undefined } +0ms
You are trying to create a migration for Sqlite database /dev.db.

Running on Windows 10. Git-Bash shell. I tried taking out the binarytargets line in the schema.prisma file with no change.

However, if I kill the command and re-run it, without deleting the dev.db file it works. Continuing with the 'db up' command works

Hi @amaline Just pushed new packages and a release that resolved issues like this specific to Windows users. See: https://github.com/redwoodjs/redwood/releases/tag/v0.2.5

If upgrading doesn’t fix the issue, please do open a new issue as needed. But 🤞 v0.2.5 gets you going!

@amaline To be clear you’ll need to create a new app from scratch so that it pulls down the latest stuff with yarn create redwood-app

Was this page helpful?
0 / 5 - 0 ratings