ActiveRecord::StatementInvalid: PG::Error: ERROR: must be owner of database

妖精的绣舞 提交于 2019-12-11 06:59:07

问题


I'm new to rails , Some errors occurred when I tried to run bundle exec rake test:prepare , Same question had been asked Click here ,I have included the psql output. Anyone can help? Thank you.

I got flowing errors :

rake aborted!
ActiveRecord::StatementInvalid: PG::Error: ERROR:  must be owner of database testp00
: DROP DATABASE IF EXISTS "testp00"
/Users/snailwalker/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `exec'
/Users/snailwalker/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
/Users/snailwalker/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:435:in `block in log'
/Users/snailwalker/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-(required)>'
/Users/snailwalker/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:370:in `block (3 levels) in <top (required)>'
Tasks: TOP => db:test:load => db:test:purge
(See full trace by running task with --trace)

psql :

   snailwalker=# \l
                                     List of databases
       Name        |    Owner    | Encoding | Collate | Ctype |      Access privileges      
-------------------+-------------+----------+---------+-------+-----------------------------
 devep00           | snailwalker | UTF8     | C       | UTF-8 | 
 myapp_development | snailwalker | UTF8     | C       | UTF-8 | 
 myapp_test        | snailwalker | UTF8     | C       | UTF-8 | 
 postgres          | snailwalker | UTF8     | C       | UTF-8 | 
 snailwalker       | snailwalker | UTF8     | C       | UTF-8 | 
 template0         | snailwalker | UTF8     | C       | UTF-8 | =c/snailwalker             +
                   |             |          |         |       | snailwalker=CTc/snailwalker
 template1         | snailwalker | UTF8     | C       | UTF-8 | =c/snailwalker             +
                   |             |          |         |       | snailwalker=CTc/snailwalker
 testp00           | snailwalker | UTF8     | C       | UTF-8 | 
(8 rows)

databse.yml:

  development:
  adapter: postgresql
  encoding: unicode
  database: devep00
  pool: 5
  username: taouan
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: testp00
  pool: 5
  username: taouan
  password:

回答1:


Thanks RAJ for reminding me to check the database.yml file ,i put a value for username somehow and i forgot it, by default it should be a nil, So i deleted username: "taouan " then run bundle exec rake test:prepare it worked. Alternative way is ALTER DATABASE testp00 OWNER TO "taouan"



来源:https://stackoverflow.com/questions/25610753/activerecordstatementinvalid-pgerror-error-must-be-owner-of-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!