2017-10-09 51 views
0

我试图将我的Rails应用程序的数据库从SQLite3迁移到Postgresql,但没有发现这一切很容易。我正在关注这个Railscast(http://railscasts.com/episodes/342-migrating-to-postgresql)。从SQLite3迁移到Postgresql的Rails应用程序

我已经编辑我的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',并且我删除了SQLite3 gem。我已经安装了Postgresql 9.6.3。

接下来我安装了水龙头宝石(0.3.24)。在此之后我尝试“耙分贝:创建:全”返回,但该错误信息是:

fe_sendauth: no password supplied 
Couldn't create database for {"adapter"=>"postgresql", "pool"=>5, 
"timeout"=>5000, "database"=>"db/development.postgresql"} 
rake aborted! 

我在这个网站,我需要做的Heroku迁移阅读 - “Heroku的运行耙分贝:迁移',但是当我尝试这个时,返回相同的错误。

我真的不知道这个错误信息是什么意思 - 我认为这可能与conf_hba文件或pgAdmin有关,但我不明白这些工作是如何工作的。

帮助将不胜感激,谢谢:-)

回答

0

您的文件,以提供与你的Postgres数据库的password & username作为 ``

 
default: &default 
    adapter: postgresql 
    encoding: unicode 
    pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 
    timeout: 5000

development: <<: *default database: performance_rails_develop username: postgres password: password pool: 5

test: <<: *default database: performance_rails_test username: postgres password: password

production: <<: *default database: db/production.sqlite3

+0

你的意思,你只需输入用户名和你自己选择的密码在你的database.yml文件中? – Robert

+0

否@Robert此用户名和密码是数据库用户名和密码。 –

+1

对不起,我对这款游戏相当陌生。我如何找出我的数据库用户名和密码? – Robert