Rails 迁移错误“参数数量错误”

问题描述 投票:0回答:1

我无法迁移,出现此错误:

StandardError:发生错误,此迁移和所有后续迁移均已取消:

原因:
ArgumentError:参数数量错误(给定 2,预期 1) /home/ciaranmurphy/cashanalytics/db/migrate/20130614160852_add_first_name_last_name_user_type_values_to_user.rb:3 > :in

change'   /home/ciaranmurphy/cashanalytics/lib/tasks/multitenant.rake:32:in 
区块(2 级),位于 '
/home/ciaranmurphy/cashanalytics/lib/tasks/multitenant.rake:18:in
block in migrate_each'   /home/ciaranmurphy/cashanalytics/app/services/tenant.rb:132:in 
with_public' /home/ciaranmurphy/cashanalytics/lib/tasks/multitenant.rake:16:in
migrate_each'   /home/ciaranmurphy/cashanalytics/lib/tasks/multitenant.rake:31:in 
块中 '
任务:TOP => db:migrate
(通过使用 --trace 运行任务查看完整跟踪)

我尝试了迁移和跟踪,但没有解决问题

ruby-on-rails migration trace rspec-rails
1个回答
0
投票

没有实际的迁移文件很难说,但请确保您的

cashanalytics/db/migrate/20130614160852_add_first_name_last_name_user_type_values_to_user.rb
文件看起来像这样:

class AddFirstNameLastNameUserTypeValuesToUser < ActiveRecord::Migration[7.1]
  def change
    add_column :user, :first_name, :string
    add_column :user, :last_name, :string
    # guessing the data type here.May also be a reference.
    add_column :user, :user_type, :integer
  end
end
© www.soinside.com 2019 - 2024. All rights reserved.