Hi !
I succeed to set and deploy my Phoenix app with a PostgreSQL database. The migrations are ok on deployment, but when i try to add a comment in a post it’s not working.
I use Docker and Docker Compose and in my docker-compose.yml file i put the local database variables.
I don’t know where to put the production database variables
If you created your app with fly launch and accepted the “Add postgres database” option flyctl should have created a database and added a DATABASE_URL secret for you. Otherwise, if you have you want to use an already running postgres app. flyctl postgres attach should have the same. To make sure the secret on your exists you can run flyctl secrets list.
Hi @sevb just to be clear: your app on Fly.io doesn’t know about your docker-compose.yml file.
If you’ve used fly launch to detect and set up a Phoenix app with a Fly Postgres database, values for SECRET_KEY_BASE and DATABASE_URL will have been generated and set as secrets on your deployed app.
You can check which secrets are set on your app with fly secrets list, and they are available as environment variables within your app’s VM, so you can actually see what’s there by popping a shell on the running app.
One thing you can’t get in plain text again are the postgres user credentials that get printed out when you create the database.
Yes i’ve done that and checked if the secrets have been generated with the fly secrets list command. And it’s ok.
Just to be more specific, I have a Gitlab CI CD and i deploy in fly.io when pushing in main branch.
I don’t know what i’m doing wrong but at least when i try to add a comment in my blog in production, the comment does not appear (it’s working in local).
I tried to connect to the Postgres app with flyctl postgres connect -a <my_db_app_name>, i think the shell is ok (it displays a line with postgres=#), but then I don’t know how to access logs
And when i run fly logs in my phoenix app, it does not show anything when i try to save a comment
Sorry, i’m a real newbie as you can see
Maybe i have an idea for my problem, it’s maybe not a database bug but a permission one (i only show comments when they are validated by the admin and i forgot to do it in production )
Do you know how I can do a sql request in CLI in my postgres database ?
I have to run flyctl postgres connect -a <my_db_app_name> maybe ?
Ok i found the way to connect and use psql to display the tables but i think i have a bigger problem, it does not show anything in my production database
I found the solution to my problem. It was not a problem of database config at all
I thought that my migrations were not running but in fact, i was not connected to the real db in psql.
To connect to my db, i had to list all the databases with \l and after that connect to my app db with \c <name_of_the_db_showed_in_the_list>, and it works !
Then i just had to give the admin role to my user, and then i was able to see the comments, approve or delete them and so on