0

I've developped an API with Node.Js, Express, Prisma and Mysql in local firstly. After that it works, I have deployed my API on Heroku and I took the ClearDB add-on to have a Mysql DB on Heroku.

So the deployment is OKAY when I go on my root root URI I have the "Cannot GET /" message, and when I try to connect to my ClearDB with MysqlWorkbench I have my tables, columns etc... The main problem is from Prisma.

When I go to the "Run console" of my Heroku's project, the command npx prisma init works perfectly BUT when I type npx prisma migrate deploy || dev or also if I try to npx prisma db push I have this error =>

Error: Get Config: Schema parsing - Error while interacting with query-engine-node-api library Error code: P1012 error: Environment variable not found: DATABASE_URL. --> schema.prisma:10 | 9 | provider = "mysql" 10 | url = env("DATABASE_URL") |

All my code is in a GitHub repo, I've configured my .env (which is in the root folder of my server) like this :

DATABASE_URL="mysql://<username>:<my-password>@eu-cdbr-west-30.cleardb.net/heroku_36d295ebb6686a2"
NODE_ENV="development"
APP_SECRET="jwtsecret12"
NODE_PATH="./src"

ACCESS_TOKEN_SECRET="651651651848754cdfce9fz8ef4ef54se8f4sef48s69ef84e"

I hope you have all the informations that you need to help me :)

PS : Locally my project works perfectly

Waiting for your answers, thank you very much !

2
  • Please share your GitHub repo Commented Aug 24, 2022 at 12:47
  • Are you still having trouble with this? Commented Sep 26, 2022 at 17:35

1 Answer 1

0

Your .env file is irrelevant. It should not be used on Heroku (and should not be tracked in your repository).

ClearDB provides an environment variable called CLEARDB_DATABASE_URL, not DATABASE_URL. You can either change your code to use this variable instead of DATABASE_URL, or you can set DATABASE_URL to the same value:

Retrieve your database URL by issuing the following command:

heroku config | grep CLEARDB_DATABASE_URL
CLEARDB_DATABASE_URL => mysql://adffdadf2341:[email protected]/heroku_db?reconnect=true

Copy the value of the CLEARDB_DATABASE_URL config variable.

If you’re using Ruby on Rails and the mysql2 gem, you will need to change the mysql:// scheme in the CLEARDB_DATABASE_URL to mysql2://

heroku config:set DATABASE_URL='mysql://adffdadf2341:[email protected]/heroku_db?reconnect=true'
Adding config vars:
DATABASE_URL => mysql2://adffd...b?reconnect=true
Restarting app... done, v61.

The connection information for Heroku Postgres can change at any time, but since the ClearDB documentation provides the preceding guidance I would hope that it does not do so.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.