soundcloud / lhm

Online MySQL schema migrations
BSD 3-Clause "New" or "Revised" License
1.83k stars 190 forks source link

Fixed an incompatibility issue with the jdbcmysql adapter that's used for JRuby apps #128

Open otzy007 opened 9 years ago

otzy007 commented 9 years ago

The mysql2 gem returns an Array but the activerecord-jdbcmysql-adapter It uses a hash that looks like this: {"Table"=>"servers", "Create Table"=>"CREATE TABLE servers}

without this fix the following exception is raised:

StandardError: An error has occurred, all later migrations canceled:

undefined method `last' for #<Hash:0xaba4a33>/Users/andrei/.rvm/gems/jruby-1.7.20/bundler/gems/lhm-8d6e8fdfa3b2/lib/lhm/table.rb:43:in `ddl'
/Users/andrei/.rvm/gems/jruby-1.7.20/bundler/gems/lhm-8d6e8fdfa3b2/lib/lhm/table.rb:43:in `ddl'
/Users/andrei/.rvm/gems/jruby-1.7.20/bundler/gems/lhm-8d6e8fdfa3b2/lib/lhm/table.rb:50:in `parse'
/Users/andrei/.rvm/gems/jruby-1.7.20/bundler/gems/lhm-8d6e8fdfa3b2/lib/lhm/table.rb:28:in `parse'
/Users/andrei/.rvm/gems/jruby-1.7.20/bundler/gems/lhm-8d6e8fdfa3b2/lib/lhm.rb:46:in `change_table'
/Users/andrei/projects/cloudstats/db/migrate/20151027094647_add_more_counters_to_server.rb:5:in `up'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:370:in `up'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:410:in `migrate'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:410:in `migrate'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:389:in `migrate'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:528:in `migrate'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:720:in `migrate'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:777:in `ddl_transaction'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:719:in `migrate'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:700:in `migrate'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:570:in `up'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/migration.rb:551:in `migrate'
/Users/andrei/.rvm/gems/jruby-1.7.20/gems/activerecord-3.2.22/lib/active_record/railties/databases.rake:193:in `(root)'

This issue affects both the 3.0 and 2.2 versions