我正试图将Rails应用程序的数据库从SQLite3迁移到Postgresql,但发现这一点并不容易。我在跟踪这个Railscast(http://railscasts.com/episodes/342-migrating-to-postgresql)。
我已经将我的database.yml文件编辑为以下内容:
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: db/development.postgresql
test:
<<: *default
database: db/test.postgresql
production:
<<: *default
database: db/production.postgresql
我在这里所做的只是将所有写着"SQLite3"的部分更改为"postgresql"。这与Railscast不同,但我猜它已经过时了(2012年)。
我已经安装了gem"pg","~>0.21.0",并删除了SQLite3gem。我已经安装了Postgresql9.6.3。
接下来我安装了taps-gem(0.3.24)。之后我尝试了"rake-db:create:all",但返回的错误消息如下:
fe_sendauth: no password supplied
Couldn't create database for {"adapter"=>"postgresql", "pool"=>5,
"timeout"=>5000, "database"=>"db/development.postgresql"}
rake aborted!
我在这个网站上读到,我可能需要进行Heroku迁移-"Heroku run rake db:migrate",但当我尝试时,会返回相同的错误。
我真的不知道这个错误消息是什么意思——我认为这可能与conf_hba文件或pgAdmin有关,但我也不明白这些是如何工作的。
非常感谢您的帮助,谢谢:-)
您必须提供password
&文件中postgres数据库的username
`
默认值:&违约适配器:postgresql编码:unicode池:<%=ENV.fetch("RAILS_MAX_THREADS"){5}%>超时:5000`开发:<lt;:*违约数据库:performance_rails_develop用户名:postgres密码:密码池:5
测试:<lt;:*违约数据库:performance_rails_test用户名:postgres密码:密码
生产:<lt;:*违约数据库:db/production.sqlite3