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
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.
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:
, notpostgresql:
.Second, it looks like you are trying to connect as user
postgres
with password2341/
, but you didn’t URI-encode the password properly. It would have to be2341%2F
.Finally, the parameter
schema
does not exist.Never, under no circumstance, run your application with a superuser.