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

时间:2016-10-21 16:57:53

标签: ruby-on-rails db2 rake ibm-cloud dashdb

我正在尝试在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

1 个答案:

答案 0 :(得分:1)

ibm_db Rails Adapater尚不支持Rails 5。