skip to Main Content

I used an URI in .env to connect my code to the database of my app, but it connected to the postgres database instead of the database "workout-app" and I don’t know how to fix that. My application created tables in the wrong database.

This is my .env file:

NODE_ENV = development
DATABASE_URL = postgresql://postgres:2341/@localhost:5432/workout-app?schema=public
ACCESS_TOKEN = SDFvmtee3t

I tried to rename database postgres, but it is imposible. I checked if the link is correct 1000 times and I don’t know what’s the problem.

2

Answers


  1. Chosen as BEST ANSWER

    I'm just a beginner and I don't know how this happened, but the problem was solved when I tried to push the tables with the server turned off. If the server was turned on, then prisma asked to unlink a certain file from node models. Sorry for wasting your time.


  2. The connection URI would be the one described in the node-postgres documentation.

    In that case, the connection URI is wrong.

    First, the scheme should be postgres:, not postgresql:.

    Second, it looks like you are trying to connect as user postgres with password 2341/, but you didn’t URI-encode the password properly. It would have to be 2341%2F.

    Finally, the parameter schema does not exist.

    Never, under no circumstance, run your application with a superuser.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search