Full-stack dev shipping Django/React SaaS and Shopify stores since 2018. 37 client projects, 11 live Shopify builds. I write production war stories so you don’t repeat my outages.
Hey Andre thanks for your time. I actually saw this earlier and did the commands but rails db:setup threw the error on the SO question. But when I ran rails db:migrate it generated a shema.rb on the db folder with data on it even if I haven't written any schemas.
We typically see CONNECT privilege issues where applications try to create databases as part >of db:setup, as the user provided does not have permission to create or drop databases.
For Rails apps you should look to use db:schema:load, db:structure:load or db:migrate instead >of db:setup.
Full-stack dev shipping Django/React SaaS and Shopify stores since 2018. 37 client projects, 11 live Shopify builds. I write production war stories so you don’t repeat my outages.
hmmm.. I think you still misunderstood the answer above.
So I think the problem you have, lies in rails db:setup because of those commands needs permission to create/drop the database which is it needs more authorization than just privileges for doing anything in one database.
all this time, you just give all privileges to one database like you mention it on your question at SO.
GRANT ALL PRIVILEGES ON DATABASE db_name TO user_name;
GRANT CONNECT ON DATABASE db_name TO user_name;
Those command just give authorization to user_name for have all_privileges and connect to one database which is db_name.
But, rails db:setup need permission beyond that. those command need to create/drop database(like db_name not just permission to access) which still not provide from the command you give it to the user_name.
So my suggestion to you,
You can add permission to create database also to your DB user(user_name).
Or try to find other command from rails like db:schema:load, db:structure:load, db:migrate which can fulfill your needs without give more permission to your user.
Full-stack dev shipping Django/React SaaS and Shopify stores since 2018. 37 client projects, 11 live Shopify builds. I write production war stories so you don’t repeat my outages.
highcenoid=# ALTER USER highcenoid CREATEDB;
ALTER ROLE
highcenoid=# GRANT ALL PRIVILEGES ON DATABASE postgres to highcenoid;
GRANT
highcenoid=# ALTER DATABASE postgres owner to highcenoid;
ALTER DATABASE
highcenoid=# GRANT CONNECT ON DATABASE postgres to highcenoid;
GRANT
highcenoid=# \q
Then it spit out
~/Dev/RoR/project master ? rails db:setup ✔
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
Couldn't create 'dca9qlbmn4rek1' database. Please check your configuration.
rails aborted!
ActiveRecord::NoDatabaseError: FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
I don't know what to do anymore.
We're a place where coders share, stay up-to-date and grow their careers.
I answer your question at there.
This is the good url for learn about your problem: stackoverflow.com/questions/391692...
Btw, my suggestion, you can try to connect to database first from postgresql client. to make sure your permission is already right
Hey Andre thanks for your time. I actually saw this earlier and did the commands but
rails db:setupthrew the error on the SO question. But when I ranrails db:migrateit generated ashema.rbon thedbfolder with data on it even if I haven't written any schemas.help.heroku.com/63D7ALXT/why-am-i-...
Try to read from there, this is the answer:
I actually did
rails db:migratebut the schema looked like it came from one of my old Django projectshmmm.. I think you still misunderstood the answer above.
So I think the problem you have, lies in
rails db:setupbecause of those commands needs permission to create/drop the database which is it needs more authorization than just privileges for doing anything in one database.all this time, you just give all privileges to one database like you mention it on your question at SO.
Those command just give authorization to user_name for have all_privileges and connect to one database which is db_name.
But,
rails db:setupneed permission beyond that. those command need to create/drop database(like db_name not just permission to access) which still not provide from the command you give it to the user_name.So my suggestion to you,
You can add permission to create database also to your DB user(user_name).
Or try to find other command from rails like db:schema:load, db:structure:load, db:migrate which can fulfill your needs without give more permission to your user.
Thanks for that detailed reply. I did this:
Then it spit out
I don't know what to do anymore.