【问题标题】:rake db:create picking up old adapter databaserake db:create 拾取旧适配器数据库
【发布时间】:2015-09-07 13:37:09
【问题描述】:

几周前我通过向我的 database.yml 添加第二个数据库进行了实验。虽然一切正常,但我不喜欢这种方法并删除了第二个数据库的所有模型等。主数据库是 postgresql,第二个是 sqlite3。 db 位置是 database.yml 中 sqlite3 db 的绝对路径。

每隔一段时间,我会将我的生产数据库转储到服务器上并将其拉入我的开发数据库。我会这样做:

rake db:drop
rake db:create
psql -d {database} < {output from pg_dump}

我在实验后第一次尝试这个过程时,我得到了一个 rake 错误:

xuserAir:db xuser$ rake db:create
(in /Users/xuser/Work/v/vfw-post)
/Users/xuser/vfw/gnucash/export/vfwexport.gnucash already exists
vfw-post_test already exists
rake aborted!
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).

Gem::LoadError: sqlite3 is not part of the bundle. Add it to Gemfile.

我的应用程序根目录中的任何地方都没有对 sqlite3、数据库路径或任何文件名或目录的引用。 rake db 似乎正在从某个地方获取旧信息,我不知道在哪里。我可能已经将 db/development.db 设置为类似于 export.db 的符号,但这也没有了。

rake db:drop 删除了位于应用根目录之外的 sqlite3 数据库。

我删除了 database.yml 文件中的所有内容:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5

development:
  <<: *default
  database: vfw-post_development

test:
  <<: *default
  database: vfw-post_test

production:
  <<: *default
  database: vfw-post_production
  username: vfw
  # password: <%= ENV['VFW-POST_DATABASE_PASSWORD'] %>

仍然会出现同样的错误。

卡住

Rails 4.2

【问题讨论】:

  • 你能给我们看看你的 Gemfile 吗?
  • @neo 我发现了我的问题并回答了我自己的问题。我设置了一个 DATABASE_URL 环境变量,它接管了。

标签: ruby-on-rails ruby ruby-on-rails-4 rake


【解决方案1】:

我发现了它的来源。

我在实验中设置了两个数据库

DATABASE_URL=sqlite3:/Users/xuser/vfw/gnucash/export/vfwexport.gnucash

我想在部署时提供帮助。我没有删除它,它首先进入 DATABASE_URL。

【讨论】:

    猜你喜欢
    • 2012-04-13
    • 2016-05-11
    • 2013-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多