【发布时间】:2018-07-08 02:37:48
【问题描述】:
近两年来,我一直在 Windows 上使用 Ruby on Rails 创建一个应用程序,我已经拥有它。这个周末我开始将我的开发环境迁移到 Ubuntu,因为它可以运行一些 Windows 中不可用的工具/服务。
我尝试运行迁移并收到此错误消息:
$ bundle exec rake db:migrate
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
class AddAttachmentImportCsvFileToTabClientProjectCommunities < ActiveRecord::Migration[4.2]
/home/joe/.rvm/gems/ruby-2.3.3/gems/activerecord-5.1.6/lib/active_record/migration.rb:525:in `inherited'
/home/joe/workspace/asb_base/db/migrate/20170829235908_add_attachment_import_csv_file_to_tab_client_project_communities.rb:1:in `<top (required)>'
首先我尝试了错误消息中的建议,并在迁移脚本中明确声明了 Rails 版本。我使用了ActiveRecord::Migration[4.2],因为那是错误消息中的内容,然后我尝试了ActiveRecord::Migration[5.1],因为那是最初编写迁移时使用的Rails版本;没有人在 Ubuntu 中工作过。
我想这可能是因为我在 Ubuntu 上的 RoR 版本(Ruby 2.5.1/Rails 5.2.0)与 Windows 上的版本(v2.3.3/v5.1.4)不同。我明确锁定了我的 RoR 版本以使用我在 Windows 中的版本,然后运行迁移 - 仍然是相同的错误消息。
我不明白为什么 rake 认为有问题的迁移脚本是使用 Rails v4.x 编写的。甚至我写的最早的源代码(甚至在此之前)也是使用 Rails v5.x。谷歌搜索没有给我任何可靠、可用的答案 - 以前有没有人解决过这个问题?
【问题讨论】:
标签: ruby-on-rails windows ruby-on-rails-5 rake ubuntu-18.04