在 Bluemix 上部署 Rails 5 个应用程序期间出现 Rake / 适配器错误

Rake / adapter error during Rails 5 app deploy on Bluemix

我正在尝试在 IBM Bluemix 平台上使用 DashDB 服务部署 Rails 5 个应用程序。根据日志,在部署阶段似乎一切正常,直到触发 rake 命令:

...
OUT    Starting app instance (index 0) with guid 88517c00-d623-43f3-b44b-01e140cba4f6
ERR    rake aborted!
ERR    ArgumentError: wrong number of arguments (given 5, expected 3..4)
ERR    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:283:in `create_table_definition'
...

我的 manifest.yml 看起来如下:

applications:
- path: .
  buildpack: https://github.com/cloudfoundry/ruby-buildpack.git
  command: rake db:migrate && bin/rails server -p $PORT -e $RAILS_ENV
  memory: 1024M
  instances: 1
  domain: eu-gb.mybluemix.net
  name: windykacja
  host: windykacja
  disk_quota: 1024M
  services:
  - dashDB-win

这是我的 gemfile:

source 'https://rubygems.org'
ruby '2.3.0'

gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem "cf-autoconfig", "~> 0.2.1"
gem 'puma', '~> 3.0'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'rack'
gem 'devise'

group :production do
    gem 'rails_12factor'
    gem 'ibm_db'
end

group :development, :test do
  gem 'byebug', platform: :mri
end

group :development do
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'sqlite3'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

..还有最后一点细节,database.yml(但我不确定它现在是否正在使用):

default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test:
  pool: 5
  timeout: 5000
  adapter: ibm_db
  database: BLUDB

production:
  pool: 5
  timeout: 5000
  adapter: ibm_db
  database: BLUDB
  user: dash105844
  password: <%= ENV['DB_PASS'] %>

目前我只设置了一个环境变量,当然是DB_PASS。我不太确定我是否需要更多它们(比如 DATABASE_URL.. 这没有帮助)——如果有人在 Bluemix 上使用过 rails 和 DashDB / DB2,我将不胜感激。几个小时以来我一直在与此作斗争,我 运行 没主意了。干杯!

编辑

我尝试使用 Rails 4.2.5 和 Ruby 2.3.0 进行部署,但都没有用。

source 'https://rubygems.org'
ruby '2.3.0'

gem 'rails', '4.2.5'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :production do
    gem 'rails_12factor'
    gem 'ibm_db'
end

group :development, :test do
  gem 'byebug'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
  gem 'sqlite3'
end

manifest.yml:

applications:
- path: .
  buildpack: https://github.com/cloudfoundry/ruby-buildpack.git
  command: rake db:migrate && bin/rails server -p $PORT -e $RAILS_ENV
  memory: 1024M
  instances: 1
  domain: eu-gb.mybluemix.net
  name: windykacja
  host: windykacja
  disk_quota: 1024M
  services:
  - dashDB-win

日志中的错误(请注意 IBM 搞砸了,您现在需要从底部阅读日志):

DEA/200Instance (index 0) failed to start accepting connections2016-10-23T12:53:48.857+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:557:in `add_index'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:801:in `migrate'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/schema_migration.rb:32:in `create_table'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:925:in `initialize'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/tasks/database_tasks.rb:137:in `migrate'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:822:in `initialize_schema_migrations_table'2016-10-23T12:53:48.715+0200
App/0    Tasks: TOP => db:migrate2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `new'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'2016-10-23T12:53:48.715+0200
App/0    (See full trace by running task with --trace)2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `up'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:1250:in `execute'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'2016-10-23T12:53:48.715+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:2281:in `execute'2016-10-23T12:53:48.714+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:1251:in `block in execute'2016-10-23T12:53:48.714+0200
App/0    ActiveRecord::StatementInvalid: [IBM][CLI Driver][DB2/LINUXX8664] SQL1667N The operation failed because the operation is not supported with the type of the specified table. Specified table: "DASH105844.SCHEMA_MIGRATIONS". Table type: "ORGANIZE BY COLUMN". Operation: "CREATE INDEX". SQLSTATE=42858 SQLCODE=-16672016-10-23T12:53:48.713+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:1250:in `execute'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:925:in `initialize'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:1251:in `block in execute'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `up'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:2285:in `rescue in execute'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/schema_migration.rb:32:in `create_table'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `new'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:822:in `initialize_schema_migrations_table'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:2277:in `execute'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/tasks/database_tasks.rb:137:in `migrate'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:801:in `migrate'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:557:in `add_index'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'2016-10-23T12:53:48.711+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `up'2016-10-23T12:53:48.710+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/tasks/database_tasks.rb:137:in `migrate'2016-10-23T12:53:48.710+0200
App/0    Failed to execute statement due to: [IBM][CLI Driver][DB2/LINUXX8664] SQL1667N The operation failed because the operation is not supported with the type of the specified table. Specified table: "DASH105844.SCHEMA_MIGRATIONS". Table type: "ORGANIZE BY COLUMN". Operation: "CREATE INDEX". SQLSTATE=42858 SQLCODE=-16672016-10-23T12:53:48.710+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:801:in `migrate'2016-10-23T12:53:48.710+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `new'2016-10-23T12:53:48.710+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'2016-10-23T12:53:48.710+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:925:in `initialize'2016-10-23T12:53:48.710+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:822:in `initialize_schema_migrations_table'2016-10-23T12:53:48.710+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:2277:in `execute'2016-10-23T12:53:48.709+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'2016-10-23T12:53:48.709+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:1251:in `block in execute'2016-10-23T12:53:48.709+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/schema_migration.rb:32:in `create_table'2016-10-23T12:53:48.709+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:557:in `add_index'2016-10-23T12:53:48.709+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:2285:in `rescue in execute'2016-10-23T12:53:48.709+0200
App/0    ActiveRecord::StatementInvalid: RuntimeError: Failed to execute statement due to: [IBM][CLI Driver][DB2/LINUXX8664] SQL1667N The operation failed because the operation is not supported with the type of the specified table. Specified table: "DASH105844.SCHEMA_MIGRATIONS". Table type: "ORGANIZE BY COLUMN". Operation: "CREATE INDEX". SQLSTATE=42858 SQLCODE=-1667: CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations (version)2016-10-23T12:53:48.709+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'2016-10-23T12:53:48.709+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'2016-10-23T12:53:48.709+0200
App/0    /home/vcap/app/vendor/bundle/ruby/2.3.0/gems/ibm_db-3.0.4/lib/active_record/connection_adapters/ibm_db_adapter.rb:1250:in `execute'2016-10-23T12:53:48.709+0200
App/0    rake aborted!2016-10-23T12:53:48.708+0200
App/0     [1m[35m (13.8ms)[0m CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations (version)2016-10-23T12:53:48.706+0200
App/0     [1m[36m (363.7ms)[0m [1mCREATE TABLE schema_migrations (version varchar(255) NOT NULL) [0m2016-10-23T12:53:48.457+0200
DEA/200  Starting app instance (index 0) with guid 8b29e93c-2560-4396-8fb0-354041aa69d52016-10-23T12:53:33.764+0200

ibm_dbRails适配器暂不支持Rails5.