rake db:migrate with rails '~> 5.1.4', sqlite3 and sequel-rails gives NameError: uninitialized constant

rake db:migrate with rails '~> 5.1.4', sqlite3 and sequel-rails gives NameError: uninitialized constant

我正在使用以下 gem 开发一个简单的应用程序:

gem 'rails', '~> 5.1.4'
gem 'sqlite3'
gem 'sequel-rails'

当我尝试创建任何迁移时,在 instructions 之后,我收到“rake 中止! NameError: uninitialized constant” 错误。例如,如果我是 运行 这个: rails generate migration create_users,输出错误为:

rake aborted!
NameError: uninitialized constant CreateUsers

任何模型生成都会发生同样的情况。 我的 application.rb 文件显示:

  require_relative 'boot'

  require "rails"
  require "action_controller/railtie"
  require "action_mailer/railtie"
  require "sprockets/railtie"
  require "rails/test_unit/railtie"
  # Pick the frameworks you want:
  require "active_model/railtie"
  require "active_job/railtie"
  # require "active_record/railtie"
  require "action_controller/railtie"
  require "action_mailer/railtie"
  require "action_view/railtie"
  require "action_cable/engine"
  require "sprockets/railtie"
  require "rails/test_unit/railtie"
  require 'rails/all'

  # Require the gems listed in Gemfile, including any gems
  # you've limited to :test, :development, or :production.
  Bundler.require(*Rails.groups)

  module MyApp
    class Application < Rails::Application
      # Initialize configuration defaults for originally generated Rails version.
      config.load_defaults 5.1
      # Allowed options: :sql, :ruby.
      config.sequel.schema_format = :sql
      # Whether to dump the schema after successful migrations.
      # Defaults to false in production and test, true otherwise.
      config.sequel.schema_dump = true
      config.sequel.load_database_tasks = true
      config.sequel.load_database_tasks = :sequel
      config.sequel.logger = Logger.new($stdout)
      # config.sequel.after_connect = proc do
      #   Sequel::Model.plugin :timestamps, update_on_create: true
      # end
      # Settings in config/environments/* take precedence over those specified here.
      # Application configuration should go into files in config/initializers
      # -- all .rb files in that directory are automatically loaded.
    end
  end

database.yml 有:

development:
  adapter: sqlite3 # Also accept sqlite3
  database: db/mydatabase.sqlite # Path to db relative to Rails root

而我的迁移20180214121521_create_users.rb内容是:

Sequel.migration do
  change do
    create_table :users do
      primary_key :id
    end
  end
end

如果能帮助解决这个问题,我们将不胜感激。 :)

解决方案是删除:require 'rails/all'config.sequel.load_database_tasks = :sequel。我现在工作正常。