fly postgres attach not working properly

Ok so, i have a app and a postgres DB, they are working just fine, i have create another app and wanted to link both app to the same DB, i did run the fly postgres attach, it did create another user and this user has the permissions required to run queries, but when i run the other app it says the relations dont exists, as it was a empty DB, but i only have one DB in my account, i try to debbug a little, i have connected the DB in my pgadmin, i select the roles and both accounts for both apps are there, the conection string seems fine too, i just dont know what to do anymore. let me know what information you guys need

hi @Alex-Grupo

The fly postgres attach command creates a new database and user in your Postgres cluster. The database name by default is the same as the consuming app. Did you use fly postgres attach for the first app you connected? If yes, then the database name should be the same as the name of the first app (with dashes replaced by underscores).

To connect your second app to the same db, try using the --database-name option with fly postgres attach:

fly postgres attach <postgres app name> --app <app-2-name> --database-name <app_1_name>

Yeah, I figured it out last night, but it was kinda late and I forgot to mention it here. Basically, what happened was the name of the database isn’t the same as it shows in the app’s dashboard; it’s the host. For example, my app name is app-1, and the database is app-1-db. The Fly Postgres attach had assigned the name of the database to app-1-db, but in reality, it’s the host. The name of the database is app-1, without the -db. I don’t know if I messed up somehow, but it looks like a bug in the attach or something. Anyhow, thanks for the help, and sorry for not updating the thread. It was kinda late last night when I figured it out.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.