在部署时迁移数据库更改时Capistrano失败

时间:2016-02-06 23:22:03

标签: ruby-on-rails capistrano3

我的开发设置没有解决下面描述的问题。

我使用capistrano部署到生产中,当我进行新的数据库迁移时,我在部署时遇到以下错误 - 这些迁移已成功开发。 我将我的DB文件夹链接到deploy.rb

中的共享

任何想法??

DEBUG [a75e33cf]    Tasks: TOP => db:migrate
(See full trace by running task with --trace)
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 192.168.2.103: Exception while executing on host 192.168.2.103: rake exit status: 1
rake stdout: == 20160204094713 AddColumnToCatalog: migrating ===============================
-- remove_index("instances", ["catalog_id"], {:name=>"index_instances_on_catalog_id"})
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (3 for 1..2)/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:578:in `remove_index'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:665:in `block in method_missing'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:634:in `block in say_with_time'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:634:in `say_with_time'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:654:in `method_missing'
/home/deploy/apps/phototank/releases/20160206231645/db/migrate/20160204094713_add_column_to_catalog.rb:3:in `change'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:608:in `exec_migration'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:591:in `block in migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:590:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:768:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:1044:in `block in ddl_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/transactions.rb:220:in `transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:1044:in `ddl_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:959:in `block in migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:955:in `each'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:955:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `up'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:801:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
ArgumentError: wrong number of arguments (3 for 1..2)
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:578:in `remove_index'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:665:in `block in method_missing'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:634:in `block in say_with_time'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:634:in `say_with_time'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:654:in `method_missing'
/home/deploy/apps/phototank/releases/20160206231645/db/migrate/20160204094713_add_column_to_catalog.rb:3:in `change'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:608:in `exec_migration'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:591:in `block in migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:590:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:768:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:1044:in `block in ddl_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/transactions.rb:220:in `transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:1044:in `ddl_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:959:in `block in migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:955:in `each'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:955:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `up'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:801:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
rake stderr: Nothing written

SSHKit::Runner::ExecuteError: Exception while executing on host 192.168.2.103: rake exit status: 1
rake stdout: == 20160204094713 AddColumnToCatalog: migrating ===============================
-- remove_index("instances", ["catalog_id"], {:name=>"index_instances_on_catalog_id"})
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (3 for 1..2)/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:578:in `remove_index'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:665:in `block in method_missing'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:634:in `block in say_with_time'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:634:in `say_with_time'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:654:in `method_missing'
/home/deploy/apps/phototank/releases/20160206231645/db/migrate/20160204094713_add_column_to_catalog.rb:3:in `change'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:608:in `exec_migration'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:591:in `block in migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:590:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:768:in `migrate'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:1044:in `block in ddl_transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/home/deploy/apps/phototank/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'

1 个答案:

答案 0 :(得分:1)

迁移中的语法错误。 remove_index方法采用一个标准参数和命名参数。有问题的迁移有两个标准参数和一个命名参数。

http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/remove_index

remove_index("instances", ["catalog_id"], {:name=>"index_instances_on_catalog_id"})

应该是

remove_index("instances", column: 'catalog_id', name: 'index_instances_on_catalog_id')

这是未经测试的代码,因此请提前验证。您可以获取生产数据库的副本并在本地运行rake db:migrate以进行测试和调试。