#ruby-on-rails #db2 #rake #ibm-cloud #dashdb
#ruby-on-rails #db2 #rake #ibm-cloud #dashdb
Вопрос:
Я пытаюсь развернуть приложение Rails 5 с помощью службы dashDB на платформе IBM Bluemix. Согласно журналам, все, кажется, работает нормально на этапе развертывания, пока не будет запущена команда 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'
...
Мой манифест.yml выглядит следующим образом:
applications:
- path: .
buildpack: https://github.com/cloudfoundry/ruby-buildpack.git
command: rake db:migrate amp;amp; 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: amp;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 .. что не помогло) — я был бы признателен за любую помощь от кого-либо, имеющего опыт использования rails и dashDB / DB2 на Bluemix. Я борюсь с этим уже несколько часов, и у меня закончились идеи. Приветствия!
EDIT
I’ve tried to deploy with Rails 4.2.5 and Ruby 2.3.0 but it didn’t work either.
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 amp;amp; 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:
ibm_db
Rails Adapter еще не поддерживает Rails 5.
Комментарии:
1. Я пробовал те же настройки в Rails 4.2.0 и Ruby 2.2.2 — тоже не сработало.
2.
rake
Ошибка, которую вы показываете, возникает из-за того, что Rails 5 еще не поддерживается. Возможно, опубликуйте ошибки, которые вы получаете с Rails 4.2?3. Я только что отредактировал свой вопрос с помощью Rails 4.2.5 setup и сообщений об ошибках из журналов сервера.
4. Еще одна вещь — я только что обнаружил, что удаление командной строки из манифеста. yml действительно позволил успешно собрать и развернуть приложение .. и, похоже, оно работает нормально. Это больше не сбой, и база данных обновляется!
5. Последний комментарий: Вы должны знать, что dashDB действительно предназначена для аналитических, а не транзакционных сред. По умолчанию таблицы создаются в столбчатом формате, что влияет на производительность транзакционных приложений. Если ваше приложение Rails будет выполнять много операций обновления / удаления, вы можете столкнуться с проблемами производительности при увеличении объема данных. Вы можете избежать этого, если сможете (повторно) создать таблицы самостоятельно, указав
ORGANIZE BY ROW
вместоORGANIZE BY COLUMN
, как они, вероятно, создаются в данный момент.