Rail6 db:migrate 失败 - 参数数量错误(给定 1,预期 0)

Posted

技术标签:

【中文标题】Rail6 db:migrate 失败 - 参数数量错误(给定 1,预期 0)【英文标题】:Rail6 db:migrate fails - wrong number of arguments (given 1, expected 0) 【发布时间】:2020-09-12 00:00:14 【问题描述】:

我无法在 Windows 7 上的 Rail 6 中创建表(即成功运行 db:migrate)。

以防万一我通过安装 Ruby 2.6 开发包并执行“gem install rails”完全重新安装了 Rails,这对我来说安装了 Rails 6.0.3.1

我创建了一个新项目,做的第一件事是生成一个“客户”模型,之后我在 db:migrate 命令失败后立即运行它,说“给出了错误数量的参数”。见下文。

C:\Apps\rails>cd cmdb

C:\Apps\rails\cmdb>rails generate model Customer string:name

      invoke  active_record
      create    db/migrate/20200525080817_create_customers.rb
      create    app/models/customer.rb
      invoke    test_unit
      create      test/models/customer_test.rb
      create      test/fixtures/customers.yml

C:\Apps\rails\cmdb>rails db:migrate

== 20200525080817 CreateCustomers: migrating ==================================
-- create_table(:customers)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (given 1, expected 0)
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:4:in `block in change'
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'

Caused by:
ArgumentError: wrong number of arguments (given 1, expected 0)
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:4:in `block in change'
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

The migration.rb was generated and is shown below:-



class CreateCustomers < ActiveRecord::Migration[6.0]

  def change

    create_table :customers do |t|

      t.name :string

      t.timestamps
    end

  end

end

带有完整跟踪的重新运行粘贴在下面:-

C:\Apps\rails\cmdb>rails db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:migrate
== 20200525080817 CreateCustomers: migrating ==================================
-- create_table(:customers)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (given 1, expected 0)
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:4:in `block in change'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:309:in `create_table'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:890:in `block in method_missing'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:858:in `block in say_with_time'
C:/Ruby26-x64/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:858:in `say_with_time'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:879:in `method_missing'
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:3:in `change'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:828:in `exec_migration'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
C:/Ruby26-x64/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:811:in `block in migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'

C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:810:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1002:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in tra
nsaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_
transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in
 synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchroniz
e'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transacti
on'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'

C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:212:in `transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `ddl_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1231:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1061:in `up'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1036:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
C:/Ruby26-x64/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/command.rb:48:in `invoke'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'

Caused by:
ArgumentError: wrong number of arguments (given 1, expected 0)
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:4:in `block in change'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:309:in `create_table'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:890:in `block in method_missing'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:858:in `block in say_with_time'
C:/Ruby26-x64/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:858:in `say_with_time'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:879:in `method_missing'
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:3:in `change'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:828:in `exec_migration'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
C:/Ruby26-x64/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:811:in `block in migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'

C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:810:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1002:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in tra
nsaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_
transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in
 synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchroniz
e'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transacti
on'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'

C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:212:in `transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `ddl_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1231:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1061:in `up'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1036:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
C:/Ruby26-x64/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/command.rb:48:in `invoke'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate

C:\Apps\rails\cmdb>

【问题讨论】:

了解更多信息。我在使用已安装的 SQLITE3 的开发环境中。 C:\Apps\rails\cmdb>sqlite3 --version 3.31.1 2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6 【参考方案1】:

如果其他人想知道为什么会这样: 我生成了一个与我的模型同名的迁移并开始收到TypeError: superclass mismatch for class MyCustomClassName 错误。然后我将迁移类重命名为CreateMyCustomClassNameTable,但将其文件名保留为相同的20201217095257_my_custom_class_name.rb,这会产生ArgumentError: wrong number of arguments (given 2, expected 0..1) 错误。将文件重命名为 20201217095257_create_my_custom_class_name_table.rb 解决了我的问题。

【讨论】:

【参考方案2】:

您错误地生成了迁移。

列名在前,数据类型在后。将以下命令与您使用的命令进行比较。

rails generate model Customer name:string

你可以通过运行快速修复它

rails destroy model Customer

然后使用我上面分享的generate 命令重新生成迁移。

【讨论】:

非常感谢阿米特 - 你是明星。 直接去迁移文件改一下就可以了,而不是彻底破坏模型?? rails g model 做了很多事情。因此,如前所述撤消它并重做将使生活更简单。【参考方案3】:

我最近遇到了类似的问题,下面是我得到的错误:

-- create_table(:workers)
rails aborted!
StandardError: An error has occurred, all later migrations canceled:

wrong number of arguments (given 1, expected 0)
/home/wint3r/Learn/RubyOnRails/AssetManager/db/migrate/20210516062205_create_workers.rb:9:in `block in change'
/home/wint3r/Learn/RubyOnRails/AssetManager/db/migrate/20210516062205_create_workers.rb:3:in `change'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/rails:5:in `<top (required)>'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/spring:10:in `block in <top (required)>'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/spring:7:in `<top (required)>'

Caused by:
ArgumentError: wrong number of arguments (given 1, expected 0)
/home/wint3r/Learn/RubyOnRails/AssetManager/db/migrate/20210516062205_create_workers.rb:9:in `block in change'
/home/wint3r/Learn/RubyOnRails/AssetManager/db/migrate/20210516062205_create_workers.rb:3:in `change'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/rails:5:in `<top (required)>'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/spring:10:in `block in <top (required)>'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:migrate

在我的案例中,出现问题是因为我尝试将 t.timestamps 用于自定义日期时间字段“emp_joining_date”,我通过将类型从 t.timestamps 更改为 t.datetime 解决了这个问题

【讨论】:

以上是关于Rail6 db:migrate 失败 - 参数数量错误(给定 1,预期 0)的主要内容,如果未能解决你的问题,请参考以下文章

使用模板元编程检测函数可以采用的最大参数数

Python 函数中的最大参数数是多少?

Python 函数中的最大参数数是多少?

每个数据库提供程序类型允许的最大参数数是多少?

可以在C ++中使用动态分配的参数数创建函数吗?

php mysqi bind_param 变量数与准备好的语句中的参数数不匹配[重复]