繁体   English   中英

在部署时迁移数据库更改时的Capistrano故障

[英]Capistrano failure when migrating DB changes on deploy

我的开发设置可以解决以下所有问题。

我使用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'

迁移中的语法错误。 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进行测试和调试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM