This project is archived and is in readonly mode.

#2599 ✓invalid
Noel Gomez

remove_column of type :reference fails

Reported by Noel Gomez | May 2nd, 2009 @ 01:48 AM | in 2.x

Rails 2.3.2

def self.up

add_column :menu_items, :x, :reference

end

def self.down

remove_column :menu_items, :x

end

on rollback get error with trace:

Invoke db:rollback (first_time) Invoke environment (first_time) Execute environment Execute db:rollback == CreateMenuItemPrices: reverting =========================================== -- remove_column(:menu_items, :x) rake aborted! An error has occurred, this and all later migrations canceled:

You have a nil object when you didn't expect it! The error occurred while evaluating nil.to_sym /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/schema_definitions.rb:467:in column' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:348:incopy_table' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:342:in each' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:342:incopy_table' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:104:in create_table' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:340:incopy_table' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:334:in move_table' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:327:inalter_table' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in transaction' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:326:inalter_table' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:258:in remove_column' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:257:ineach' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:257:in remove_column' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:352:insend' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:352:in method_missing' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:328:insay_with_time' /usr/local/lib/ruby/1.8/benchmark.rb:293:in measure' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:328:insay_with_time' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:348:in method_missing' ./db/migrate//20090501010432_create_menu_item_prices.rb:18:indown_without_benchmarks' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:282:in send' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:282:inmigrate' /usr/local/lib/ruby/1.8/benchmark.rb:293:in measure' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:282:inmigrate' (DELEGATION):2:in __send__' (__DELEGATION__):2:inmigrate' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:486:in migrate' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:560:incall' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:560:in ddl_transaction' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:136:intransaction' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:182:in transaction' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:560:inddl_transaction' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:485:in migrate' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:472:ineach' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:472:in migrate' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:404:indown' /Users/noel/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/migration.rb:396:in rollback' /Users/noel/.gem/ruby/1.8/gems/rails-2.3.2/lib/tasks/databases.rake:155 /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:incall' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:ineach' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:ininvoke_with_call_chain' /usr/local/lib/ruby/1.8/monitor.rb:242:in synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:ininvoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:ininvoke_task' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:ineach' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:instandard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:inrun' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:inrun' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31 /usr/local/bin/rake:19:in load' /usr/local/bin/rake:19

Comments and changes to this ticket

  • qoobaa

    qoobaa May 6th, 2009 @ 07:04 PM

    It seems like the problem that I described few months ago:

    https://rails.lighthouseapp.com/...

    There you can find a patch (may not work with current version). I suggest closing this ticket and we've to decide how to handle non-existing types in SQLite3.

  • Noel Gomez
  • Frederick Cheung

    Frederick Cheung May 7th, 2009 @ 11:18 PM

    • State changed from “new” to “invalid”

    Aside from that, the core issue I think is that add_column :some_table, :foo, :reference adds a column called foo_id and not foo.

    remove_column doesn't know this so is trying to remove a column that doesn't exist (but checkout remove_references )

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages