【问题标题】:Upgrade to Rails 3 and lost ability to run Active Record database migrations升级到 Rails 3 并失去运行 Active Record 数据库迁移的能力
【发布时间】:2013-05-11 12:05:18
【问题描述】:

我有一个企业 Web 应用程序,由于各种原因,它与 SQL Server 以及 Mongoid 文档有 Active Record 连接。直到现在,人们一直反对更新到 Rails 3(是的,我知道,正好赶上 Rails 4)。该应用程序大部分运行良好,两个数据库相互配合。但是,我似乎失去了运行 SQL 数据库迁移的能力。

rake -T 给了我以下数据库选项:

rake db:drop                      # Drops all the collections for the database for the current Rails.env
rake db:mongoid:create_indexes    # Create the indexes defined on your mongoid models
rake db:mongoid:drop              # Drops the database for the current Rails.env
rake db:mongoid:purge             # Drop all collections except the system collections
rake db:mongoid:remove_indexes    # Remove the indexes defined on your mongoid models without questions!
rake db:purge                     # Drop all collections except the system collections
rake db:reseed                    # Delete data and seed
rake db:seed                      # Load the seed data from db/seeds.rb
rake db:setup                     # Create the database, and initialize with the seed data

rake db:migrate 只是返回,没有任何信息。

看起来 mongoid gem 可能是罪魁祸首,因为迁移适用于空白项目,并且唯一的 db 选项与 mongoid 相关。

我的问题是:升级到 rails 3 和 mongoid 3.1.3 后如何恢复 ActiveRecord 迁移?

【问题讨论】:

  • 更新:我什至试过rails g migration,新的迁移也没有被接受。

标签: sql ruby-on-rails-3 activerecord mongoid rake


【解决方案1】:

想通了,至少缺少 rake 任务部分。

事实证明,您需要在 config/application.rb 文件中包含 require 'rails/all'

这会将 db 任务返回到 rake。

【讨论】:

    猜你喜欢
    • 2011-12-29
    • 2016-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-17
    • 2020-03-16
    • 1970-01-01
    相关资源
    最近更新 更多