【问题标题】:Rails 3.1 Migrate to PostgreSQL locallyRails 3.1 本地迁移到 PostgreSQL
【发布时间】:2012-03-25 05:05:27
【问题描述】:

我想在本地使用 PostgreSQL,因为我必须在 Heroku 上使用它。我已经构建了我的应用程序,所以我需要转换我现在使用 MySQL 的内容。

我有

group :development, :test do
  gem 'pg'
end
group :production do
  gem 'pg'
end

我已经做了brew install pg。我跑了rake db:setup 并收到此错误

Couldn't create database for {"adapter"=>"sqlite3", "database"=>"db/test.sqlite3", "pool"=>5, "timeout"=>5000}
db/development.sqlite3 already exists
rake aborted!
Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.)

怎么了?

【问题讨论】:

    标签: mysql ruby-on-rails-3 postgresql


    【解决方案1】:

    您是否已更新您的 database.yml 文件以使用 pg 适配器?

    development:
        adapter: postgresql
        database: cookbook
        username: uid
        password: pwd
        host: localhost
    

    您的 database.yml 似乎仍配置为使用 SQLite。

    【讨论】:

    • 哦,我该怎么做?只需替换 sqlite3 的所有引用 -> pg?
    • 我会这样留下用户名/密码吗?或者我怎么知道要改成什么?
    • 它们需要设置为您配置的 PQSQL 帐户。您还必须将数据库从 cookbook 更改为您的数据库名称。
    猜你喜欢
    • 2012-02-29
    • 2020-09-09
    • 1970-01-01
    • 1970-01-01
    • 2014-03-24
    • 1970-01-01
    • 2011-05-13
    • 2013-09-18
    • 2019-12-27
    相关资源
    最近更新 更多