Prisma1: Unable to init existing MySQL database

Created on 20 Mar 2019  路  27Comments  路  Source: prisma/prisma1

$ env DEBUG=* prisma init hello-world
  environment FetchError: request to http://localhost:4466/management failed, reason: connect ECONNREFUSED 127.0.0.1:4466
  environment     at ClientRequest.<anonymous> (/home/eduardo/n/lib/node_modules/prisma/node_modules/node-fetch/lib/index.js:1393:11)
  environment     at ClientRequest.emit (events.js:197:13)
  environment     at ClientRequest.EventEmitter.emit (domain.js:481:20)
  environment     at Socket.socketErrorListener (_http_client.js:397:9)
  environment     at Socket.emit (events.js:197:13)
  environment     at Socket.EventEmitter.emit (domain.js:481:20)
  environment     at emitErrorNT (internal/streams/destroy.js:91:8)
  environment     at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
  environment     at processTicksAndRejections (internal/process/next_tick.js:76:17) +0ms
  environment FetchError: request to http://localhost:4466/management failed, reason: connect ECONNREFUSED 127.0.0.1:4466
  environment     at ClientRequest.<anonymous> (/home/eduardo/n/lib/node_modules/prisma/node_modules/node-fetch/lib/index.js:1393:11)
  environment     at ClientRequest.emit (events.js:197:13)
  environment     at ClientRequest.EventEmitter.emit (domain.js:481:20)
  environment     at Socket.socketErrorListener (_http_client.js:397:9)
  environment     at Socket.emit (events.js:197:13)
  environment     at Socket.EventEmitter.emit (domain.js:481:20)
  environment     at emitErrorNT (internal/streams/destroy.js:91:8)
  environment     at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
  environment     at processTicksAndRejections (internal/process/next_tick.js:76:17) +6ms
  client Sending query to cloud api +0ms
  client https://api2.cloud.prisma.sh +0ms
  client {
  client       me {
  client         id
  client         name
  client         login {
  client           email
  client         }
  client       }
  client     } +1ms
  client undefined +0ms
  client { headers: {}, agent: undefined } +1ms
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? MySQL
? Does your database contain existing data? Yes
? Enter database host 127.0.0.1
? Enter database port 3306
? Enter database user deploy
? Enter database password xxxxxxxx
TypeError: Cannot read property 'startsWith' of undefined
    at /home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/src/utils/EndpointDialog.ts:611:12
    at Array.filter (<anonymous>)
    at EndpointDialog.<anonymous> (/home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/src/utils/EndpointDialog.ts:609:37)
    at step (/home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/utils/EndpointDialog.js:43:23)
    at Object.next (/home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/utils/EndpointDialog.js:24:53)
    at /home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/utils/EndpointDialog.js:18:71
    at new Promise (<anonymous>)
    at __awaiter (/home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/utils/EndpointDialog.js:14:12)
    at EndpointDialog.selectSchema (/home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/utils/EndpointDialog.js:579:16)
    at Object.<anonymous> (/home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/src/commands/introspect/util.ts:125:41)
    at step (/home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/introspect/util.js:43:23)
    at Object.next (/home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/introspect/util.js:24:53)
    at fulfilled (/home/eduardo/n/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/introspect/util.js:15:58)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
  output Exiting with code: 1 +0ms
bu0-needs-info statustale

Most helpful comment

I'm having the same error:
Cannot read property 'startsWith' of undefined

All 27 comments

@eduardobcastro

Can you please share some a small reproduction of the problem? With the bare error message, we can't triage and fix this.

@pantharshit00 I did:
env DEBUG=* prisma init hello-world

I've just started following the getting started with an existing MySQL database.

@eduardobcastro : Can you please share your Prisma CLI version and Prisma server version using prisma version and docker ps respectively.

@divyenduz

prisma/1.29.0 (linux-x64) node-v11.12.0

The prisma init command comes before we start the server so I don't have one started at this point.

@eduardobcastro : I am unable to reproduce, what options did you choose in the init workflow? I get a dialog like the one attached in the screenshot and it works fine for me.

image

image

This should be fixed in the latest alpha: 1.31.0-alpha.3, can you please try it using npm install -g prisma@alpha

Hi @divyenduz, I've just installed the latest alpha. The error continues.

Thanks, I will test this and get back, btw, is your local MySQL empty or does it have data?

@eduardobcastro which version of mysql are you using? ran into the same issue this morning but switching from version 8 to 5.7 did the trick

@eduardobcastro which version of mysql are you using? ran into the same issue this morning but switching from version 8 to 5.7 did the trick

Same thing happen with me, after downgrade to 5.7 it works. But now I got the following error when trying to start the docker image. I'm using the latest alpha version: 1.31.0-alpha.3

Exception in thread "main" java.lang.RuntimeException: There is not passive mysql deploy connector yet!
    at scala.sys.package$.error(package.scala:26)
    at com.prisma.connectors.utils.ConnectorLoader$.loadDeployConnector(ConnectorLoader.scala:38)
    at com.prisma.local.PrismaLocalDependencies.deployConnector$lzycompute(PrismaLocalDependencies.scala:83)
    at com.prisma.local.PrismaLocalDependencies.deployConnector(PrismaLocalDependencies.scala:83)
    at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:90)
    at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
    at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
    at scala.Function0.apply$mcV$sp(Function0.scala:34)
    at scala.Function0.apply$mcV$sp$(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App.$anonfun$main$1$adapted(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:388)
    at scala.App.main(App.scala:76)
    at scala.App.main$(App.scala:74)
    at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
    at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala)

@danielsantiago I'm running the :latest docker image. It shall be 8.0

@eduardobcastro which version of mysql are you using? ran into the same issue this morning but switching from version 8 to 5.7 did the trick

Same thing happen with me, after downgrade to 5.7 it works. But now I got the following error when trying to start the docker image. I'm using the latest alpha version: 1.31.0-alpha.3

Exception in thread "main" java.lang.RuntimeException: There is not passive mysql deploy connector yet!
  at scala.sys.package$.error(package.scala:26)
  at com.prisma.connectors.utils.ConnectorLoader$.loadDeployConnector(ConnectorLoader.scala:38)
  at com.prisma.local.PrismaLocalDependencies.deployConnector$lzycompute(PrismaLocalDependencies.scala:83)
  at com.prisma.local.PrismaLocalDependencies.deployConnector(PrismaLocalDependencies.scala:83)
  at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:90)
  at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
  at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
  at scala.Function0.apply$mcV$sp(Function0.scala:34)
  at scala.Function0.apply$mcV$sp$(Function0.scala:34)
  at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
  at scala.App.$anonfun$main$1$adapted(App.scala:76)
  at scala.collection.immutable.List.foreach(List.scala:388)
  at scala.App.main(App.scala:76)
  at scala.App.main$(App.scala:74)
  at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
  at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala)

@danielsantiago check your docker-compose.yml and tell me the value that migration has

@danielsantiago I'm running the :latest docker image. It shall be 8.0

@eduardobcastro sadly couldn't make it work with the latest version of mysql had to use 5.7

Prisma doesn't support MySQL 8 yet: https://github.com/prisma/prisma/issues/3979

If you think that this issue is a duplicate of the above issue, please feel free to close it.

Hey @divyenduz before closing this issue, I would like your advice in an edge case that I faced while playing around with prisma introspect and an existing mysql database.

Figured out the problem with the version we should use [email protected] instead of 8 and this is totally fine. But once the prisma introspect process finishes and give me the datamodel.prisma file it has a couple of problems like:
1- a few table rows are duplicated for no reason since the DB schema doesn't have them duplicated.
2- when I do prisma deploy it give me a bunch of errors because the DB schema is currently using ID as Int instead of the ID or UUID type.
3- It has a lot of postgres directives like pgTable and i'm wondering if it is the correct behavior.

@mjimenez07 : Thanks for the details, this indeed looks like incorrect behaviour. I encourage you to create a separate issue for that with minimal reproduction here (maybe parts of your MySQL schema, if possible).

@divyenduz here is the issue #4283

@mjimenez07 : Thank you, please close this one if you think that this is a duplicate of MySQL 8 support issue.

I will get back on the newly created issue separately. Thanks.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

I'm having this same issue after following the above advice. My setup is as follows:

  • Windows 10: WSL Ubuntu 18 or standard CMD
  • Prisma CLI: prisma/1.34.0 (linux-x64) node-v10.16.0
  • MySQL: Community Server 5.7 running on port 3309

Stack Trace:

user1@dev006:/mnt/c/Users/user1/Documents/Projects$ prisma init ps-graphql
  command Failed to get the definition file +0ms
  command Error: Couldn鈥檛 find `prisma.yml` file. Are you in the right directory? +2ms
  init prisma init workflow called without existing directory. +0ms
  init Error: ENOENT: no such file or directory, scandir '/mnt/c/Users/user1/Documents/Projects/ps-graphql/' +1ms
  client Sending query to cloud api +0ms
  client https://api2.cloud.prisma.sh +0ms
  client {
  client       me {
  client         id
  client         name
  client         login {
  client           email
  client         }
  client       }
  client     } +1ms
  client undefined +1ms
  client { headers:
  client    { Authorization:
  client       'Bearer xxxxxxxxxxx.xxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxx' },
  client   agent: undefined } +1ms
  endpoint-dialog EndpointDialog workflow called without existing directory. +937ms
  endpoint-dialog Error: ENOENT: no such file or directory, scandir '/mnt/c/Users/user1/Documents/WORK/KHPH-INC/Projects/ps-graphql/' +0ms
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? MySQL
? Does your database contain existing data? Yes
? Enter database host localhost
? Enter database port 3309
? Enter database user dbuser
? Enter database password [hidden]

Introspecting database prestashop... !
TypeError: Cannot read property 'type' of undefined
    at _loop_3 (/mnt/c/Users/user1/AppData/Roaming/npm/node_modules/prisma/node_modules/prisma-db-introspection/src/databases/relational/relationalIntrospectionResult.ts:348:28)
    at MysqlIntrospectionResult.RelationalIntrospectionResult.hideJoinTypes (/mnt/c/Users/user1/AppData/Roaming/npm/node_modules/prisma/node_modules/prisma-db-introspection/dist/databases/relational/relationalIntrospectionResult.js:552:17)
    at MysqlIntrospectionResult.RelationalIntrospectionResult.infer (/mnt/c/Users/user1/AppData/Roaming/npm/node_modules/prisma/node_modules/prisma-db-introspection/src/databases/relational/relationalIntrospectionResult.ts:504:18)
    at MysqlIntrospectionResult.RelationalIntrospectionResult.getDatamodel (/mnt/c/Users/user1/AppData/Roaming/npm/node_modules/prisma/node_modules/prisma-db-introspection/src/databases/relational/relationalIntrospectionResult.ts:53:17)
    at MysqlIntrospectionResult.IntrospectionResult.getNormalizedDatamodel (/mnt/c/Users/user1/AppData/Roaming/npm/node_modules/prisma/node_modules/prisma-db-introspection/src/common/introspectionResult.ts:23:24)
    at EndpointDialog.<anonymous> (/mnt/c/Users/user1/AppData/Roaming/npm/node_modules/prisma/node_modules/prisma-cli-core/src/utils/EndpointDialog.ts:409:44)
    at step (/mnt/c/Users/user1/AppData/Roaming/npm/node_modules/prisma/node_modules/prisma-cli-core/dist/utils/EndpointDialog.js:43:23)
    at Object.next (/mnt/c/Users/user1/AppData/Roaming/npm/node_modules/prisma/node_modules/prisma-cli-core/dist/utils/EndpointDialog.js:24:53)
    at fulfilled (/mnt/c/Users/user1/AppData/Roaming/npm/node_modules/prisma/node_modules/prisma-cli-core/dist/utils/EndpointDialog.js:15:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  output Exiting with code: 1 +0ms

I'm having the same error:
Cannot read property 'startsWith' of undefined

Did this problem fix? I also have the same problem.
My setup is as follows:

Windows 10: standard CMD
Prisma CLI: prisma/1.34.10 (windows-x64) node-v12.13.1
MySQL: Community Server 8.0 running on port 3306

@divyenduz @mjimenez07 Is prisma fixed that mysql version problem in the new release ? I'm facing the same issue @eduardobcastro was facing. Also i'm using mysql 8 version in production. so downgrade to 5.7 is little risky for me .

Same issue we are also running MySQL 8. Why doesn't Prisma not work with MySQL 8?

MySQL 8 is supported in Prisma version 2: https://www.prisma.io/docs/more/supported-databases#overview

Turns out I had installed Prisma 1. MySQL 8 does work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sedubois picture sedubois  路  3Comments

jannone picture jannone  路  3Comments

notrab picture notrab  路  3Comments

AlessandroAnnini picture AlessandroAnnini  路  3Comments

nikolasburk picture nikolasburk  路  3Comments