【问题标题】:Getting an sqlite error when migrating after heroku deployment在 Heroku 部署后迁移时出现 sqlite 错误
【发布时间】:2017-01-23 06:32:48
【问题描述】:

所以我将我的应用程序部署到 Heroku 并安装了 gem 'pg' 并删除了 sqlite。 现在当我在本地或 Heroku 上迁移时出现此错误

Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

我该如何解决这个问题?谢谢

【问题讨论】:

    标签: ruby-on-rails sqlite heroku database-migration rails-postgresql


    【解决方案1】:

    在开发中添加"sqlite3",在production中添加"pg"

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

    【讨论】:

    • 现在我得到了这个错误 SQLite3::SQLException: duplicate column name: parent_id: ALTER TABLE "cmets" ADD "parent_id" integer,我试过 drop:all 然后创建然后迁移但是 sme 错误
    • 试试heroku run rake db:setup
    • 只需:重置我的数据库,迁移工作正常,但仍然出现错误,但现在只在视图中。这是.. ActionView::Template::Error(#<0x007fe52478d2d0>
    猜你喜欢
    • 2015-03-31
    • 2011-08-11
    • 2018-05-02
    • 1970-01-01
    • 1970-01-01
    • 2016-10-03
    • 1970-01-01
    • 1970-01-01
    • 2021-10-05
    相关资源
    最近更新 更多