Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

db:rollback fails with a def change containing an add_column for a boolean #8906

Closed
f3ndot opened this Issue · 1 comment

1 participant

@f3ndot

I ran this migration (which ran successfully):

class AddSoftDeleteToEvents < ActiveRecord::Migration
  def change
    add_column :events, :boolean, :deleted, :default => false
  end
end

and upon attempting to roll it back using db:rollback I received this error:

➜  app git:(master) bundle exec rake db:rollback --trace
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler.rb:263: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/dalli-148cac099e5d/lib/dalli/version.rb:2: warning: already initialized constant VERSION
** Invoke db:rollback (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:rollback
==  AddSoftDeleteToEvents: reverting ==========================================
-- remove_column("events", :boolean)
rake aborted!
An error has occurred, this and all later migrations canceled:

undefined method `to_sym' for nil:NilClass
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/schema_definitions.rb:229:in `column'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:502:in `block (2 levels) in copy_table'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:496:in `each'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:496:in `block in copy_table'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/schema_statements.rb:160:in `create_table'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:494:in `copy_table'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:488:in `move_table'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:481:in `block in alter_table'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:480:in `alter_table'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:418:in `block in remove_column'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:417:in `each'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:417:in `remove_column'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:466:in `block in method_missing'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:438:in `block in say_with_time'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:438:in `say_with_time'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:458:in `method_missing'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:402:in `block (4 levels) in migrate'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:401:in `each'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:401:in `block (3 levels) in migrate'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:358:in `revert'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:400:in `block (2 levels) in migrate'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:399:in `block in migrate'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:389:in `migrate'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:528:in `migrate'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `call'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `block in ddl_transaction'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/transactions.rb:208:in `transaction'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `ddl_transaction'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:719:in `block in migrate'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in `each'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in `migrate'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:574:in `down'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:656:in `move'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:562:in `rollback'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:262:in `block (2 levels) in <top (required)>'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/bin/rake:23:in `load'
/Users/justinbull/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/bin/rake:23:in `<main>'
Tasks: TOP => db:rollback

It appears the generated remove_column("events", :boolean) fails because :boolean is already a symbol?

Please advise.

Environment:
Rails version 3.2.11
Ruby MRI version 1.9.3-p194
Using RVM

@f3ndot f3ndot closed this
@f3ndot

This was a problem with the SQLite database not supporting the ability to drop columns:
http://www.sqlite.org/faq.html#q11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.