Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

can't run rake db:migrate in Rails 4.0.1 app #135

Closed
mhuggins opened this Issue Nov 30, 2013 · 8 comments

Comments

Projects
None yet
5 participants

I'm trying to run migrations, but I seem to be getting an error after adding the schema_plus gem. The issue persists even if I "remove" (by renaming to *.bak extension) all my migration files.

> brake db:create
> brake db:migrate
rake aborted!
undefined method `options_include_default?' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::SchemaCreation:0x007fe950decc40>
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/schema_plus-1.3.1/lib/schema_plus/active_record/connection_adapters/abstract_adapter.rb:179:in `add_column_options_with_schema_plus!'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:31:in `add_column_options!'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:136:in `visit_ColumnDefinition'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:14:in `visit_ColumnDefinition'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:117:in `accept'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:143:in `block in visit_TableDefinition'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:143:in `map'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:143:in `visit_TableDefinition'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/schema_plus-1.3.1/lib/schema_plus/active_record/connection_adapters/abstract_adapter.rb:229:in `visit_TableDefinition_with_schema_plus'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:117:in `accept'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:190:in `create_table'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/schema_plus-1.3.1/lib/schema_plus/active_record/connection_adapters/schema_statements.rb:31:in `create_table_with_schema_plus'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/schema_migration.rb:21:in `create_table'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/migration.rb:878:in `initialize'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/migration.rb:764:in `new'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/migration.rb:764:in `up'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/migration.rb:742:in `migrate'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/gems/activerecord-4.0.1/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/bin/ruby_executable_hooks:14:in `eval'
/Users/mhuggins/.rvm/gems/ruby-2.0.0-p247@portfolio/bin/ruby_executable_hooks:14:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

For reference, here are my Gemfile and Gemfile.lock:

Gemfile:

source 'https://rubygems.org'

gem 'rails', '4.0.1'
gem 'pg'
gem 'squeel'
gem 'schema_plus'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'haml-rails'
gem 'devise'
gem 'simple_form'
gem 'kaminari'
gem 'bootstrap-sass-rails'

group :doc do
  gem 'sdoc', require: false  # bundle exec rake doc:rails generates the API under doc/api.
end

group :development do
  gem 'better_errors'         # better error pages in dev
  gem 'binding_of_caller'     # provides console for better_errors
  gem 'quiet_assets'          # suppress log entries for assets in dev
end

group :test do
  gem 'rspec-rails'
  gem 'shoulda-matchers'
  gem 'capybara'
  gem 'capybara-webkit'
  gem 'factory_girl_rails'
end

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

Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.0.1)
      actionpack (= 4.0.1)
      mail (~> 2.5.4)
    actionpack (4.0.1)
      activesupport (= 4.0.1)
      builder (~> 3.1.0)
      erubis (~> 2.7.0)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    activemodel (4.0.1)
      activesupport (= 4.0.1)
      builder (~> 3.1.0)
    activerecord (4.0.1)
      activemodel (= 4.0.1)
      activerecord-deprecated_finders (~> 1.0.2)
      activesupport (= 4.0.1)
      arel (~> 4.0.0)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.1)
      i18n (~> 0.6, >= 0.6.4)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.37)
    arel (4.0.1)
    atomic (1.1.14)
    bcrypt-ruby (3.1.2)
    better_errors (1.0.1)
      coderay (>= 1.0.0)
      erubis (>= 2.6.6)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    bootstrap-sass-rails (3.0.2.1)
      railties (>= 3.1.0)
      sass-rails (>= 3.1.0)
    builder (3.1.4)
    capybara (2.2.0)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    capybara-webkit (1.0.0)
      capybara (~> 2.0, >= 2.0.2)
      json
    coderay (1.1.0)
    coffee-rails (4.0.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.3)
    debug_inspector (0.0.2)
    devise (3.2.2)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      thread_safe (~> 0.1)
      warden (~> 1.2.3)
    diff-lcs (1.2.5)
    erubis (2.7.0)
    execjs (2.0.2)
    factory_girl (4.3.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.3.0)
      factory_girl (~> 4.3.0)
      railties (>= 3.0.0)
    faker (1.2.0)
      i18n (~> 0.5)
    haml (4.0.4)
      tilt
    haml-rails (0.5.1)
      actionpack (~> 4.0.0)
      activesupport (~> 4.0.0)
      haml (>= 3.1, < 5.0)
      railties (~> 4.0.0)
    hike (1.2.3)
    i18n (0.6.5)
    jquery-rails (3.0.4)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.8.1)
    kaminari (0.15.0)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.25.1)
    mini_portile (0.5.2)
    minitest (4.7.5)
    multi_json (1.8.2)
    nokogiri (1.6.0)
      mini_portile (~> 0.5.0)
    orm_adapter (0.5.0)
    pg (0.17.0)
    polyamorous (0.6.4)
      activerecord (>= 3.0)
    polyglot (0.3.3)
    quiet_assets (1.0.2)
      railties (>= 3.1, < 5.0)
    rack (1.5.2)
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (4.0.1)
      actionmailer (= 4.0.1)
      actionpack (= 4.0.1)
      activerecord (= 4.0.1)
      activesupport (= 4.0.1)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.0.1)
      sprockets-rails (~> 2.0.0)
    railties (4.0.1)
      actionpack (= 4.0.1)
      activesupport (= 4.0.1)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.1.0)
    rdoc (3.12.2)
      json (~> 1.4)
    rspec-core (2.14.7)
    rspec-expectations (2.14.4)
      diff-lcs (>= 1.1.3, < 2.0)
    rspec-mocks (2.14.4)
    rspec-rails (2.14.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.14.0)
      rspec-expectations (~> 2.14.0)
      rspec-mocks (~> 2.14.0)
    sass (3.2.12)
    sass-rails (4.0.1)
      railties (>= 4.0.0, < 5.0)
      sass (>= 3.1.10)
      sprockets-rails (~> 2.0.0)
    schema_plus (1.3.1)
      rails (>= 3.2)
      valuable
    sdoc (0.3.20)
      json (>= 1.1.3)
      rdoc (~> 3.10)
    shoulda-matchers (2.4.0)
      activesupport (>= 3.0.0)
    simple_form (3.0.0)
      actionpack (>= 4.0.0, < 4.1)
      activemodel (>= 4.0.0, < 4.1)
    sprockets (2.10.1)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.0.1)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (~> 2.8)
    squeel (1.1.1)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      polyamorous (~> 0.6.0)
    thor (0.18.1)
    thread_safe (0.1.3)
      atomic
    tilt (1.4.1)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    turbolinks (1.3.1)
      coffee-rails
    tzinfo (0.3.38)
    uglifier (2.3.1)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    valuable (0.9.8)
    warden (1.2.3)
      rack (>= 1.0)
    xpath (2.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  better_errors
  binding_of_caller
  bootstrap-sass-rails
  capybara
  capybara-webkit
  coffee-rails (~> 4.0.0)
  devise
  factory_girl_rails
  faker
  haml-rails
  jquery-rails
  kaminari
  pg
  quiet_assets
  rails (= 4.0.1)
  rspec-rails
  sass-rails (~> 4.0.0)
  schema_plus
  sdoc
  shoulda-matchers
  simple_form
  squeel
  turbolinks
  uglifier (>= 1.3.0)

To ensure it relates to the schema_plus gem, I removed gem 'schema_plus' from my Gemfile and re-bundled before running rake db:migrate again, and the rake task completed normally.

I have the same issue and have had to lock the gem to v1.2.0 to avoid this error.

The options_include_default? method in ActiveRecord::ConnectionAdapters::SchemaStatements is protected which I believe is the cause of the error.

Strangely I have a colleague with exactly the same setup (using rvm, ruby 2.0.0 p247, rails 4.0.1) who does not get the error.

Upgrading to ruby-2.0.0-p353 resolved the issue for me

mhuggins commented Dec 5, 2013

I didn't mention when I opened this issue, but it occurred for me on ruby-2.0.0-p247 as well. I'll try upgrading to p353 to see if it makes a difference, but I'm kind of surprised that that alone would solve the issue since it appears to pertain to a method missing in the code.

Owner

ronen commented Dec 14, 2013

@chrismhilton thanks for finding a fix... @mhuggins does that work for you? and/or does the problem persist in rails 4.0.2?

i haven't been able to recreate this myself; rails 4.0.1 with ruby 2.0.0-p247 seems to run fine for me. maybe it's something platform-specific? (i'm on OS X)

in any case, if you've got it working, i'm inclined to just let it go, perhaps with a note in the README that some people have problems with rails 4.0.1 and ruby 2.0.0-p247 and suggest the ruby upgrade.

I had the same issue with ruby 2.0.0-p242, Rails 4.0.2, and Postgres 9.3. Upgrading to 2.0.0-p353 did fix my issue.

try to remove the Gemfile.lock then run the "bundle update" then try the migration.

I'm trying this gem in a new project, and I'm not seeing an error this time around. I'll close for now and reopen if it comes up again. Thanks!

@mhuggins mhuggins closed this Mar 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment