This project is archived and is in readonly mode.
Rails-2.3.8 db:migrate gives undefined method `length' for :any_index:Symbol
Reported by James B. Byrne | June 17th, 2010 @ 07:02 PM | in 2.3.10
I had occasion to re-run the migration for a Rails project and I get the error given below. I get this only with 2.3.8. Rails-2.3.5, to which I have reverted, does not have this problem.
$ rake -t db:migrate (in /home/byrnejb/Software/Development/Projects/proforma.git) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate == CreateSessions: migrating ================================================= -- create_table(:sessions) -> 0.0015s -- add_index(:sessions, :session_id, {:unique=>true, :name=>:idxr_sessions_session_id}) rake aborted! An error has occurred, this and all later migrations canceled: undefined method `length' for :idxr_sessions_session_id:Symbol /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/schema_statements.rb:281:in `add_index' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:352:in `send' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:352:in `method_missing' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:328:in `say_with_time' /home/byrnejb/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/benchmark.rb:293:in `measure' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:328:in `say_with_time' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:348:in `method_missing' ./db/migrate//00110_create_sessions.rb:13:in `up_without_benchmarks' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:282:in `send' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:282:in `migrate' /home/byrnejb/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/benchmark.rb:293:in `measure' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:282:in `migrate' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:365:in `__send__' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:365:in `migrate' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:491 /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:565:in `call' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:565:in `ddl_transaction' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/transactions.rb:182:in `transaction' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:565:in `ddl_transaction' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:490:in `migrate' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:477:in `each' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:477:in `migrate' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:401:in `up' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-2.3.8/lib/active_record/migration.rb:383:in `migrate' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rails-2.3.8/lib/tasks/databases.rake:112 /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:636:in `call' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:636:in `execute' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:631:in `each' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:631:in `execute' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain' /home/byrnejb/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/monitor.rb:242:in `synchronize' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:583:in `invoke' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2029:in `each' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2001:in `run' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake.rb:1998:in `run' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/bin/rake:31 /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/bin/rake:24:in `load' /home/byrnejb/.rvm/gems/ruby-1.8.7-p249/bin/rake:24
Comments and changes to this ticket
-
Étienne Barrié June 18th, 2010 @ 03:41 PM
- Tag changed from rake db:migrate rails-2.3.8 bug to rake db:migrate rails-2.3.8 bug, patch
Thanks for your report. I fixed it in the attached patch. Applies on 2-3-stable but can be cherry-picked to master too.
Meanwhile, you can just change your symbol into strings and the migrations should work.
-
James B. Byrne June 18th, 2010 @ 03:52 PM
Applied this patch and it resolves our problem with AR-2.3.8.
-
Brian Durand June 24th, 2010 @ 06:12 PM
- Tag changed from rake db:migrate rails-2.3.8 bug, patch to rake db:migrate rails-2.3.8 bug, 3.0, patch
-
Étienne Barrié June 25th, 2010 @ 02:44 PM
Yes it's also present in master. This patch still applies on both 2-3-stable and master and solves that problem.
-
James B. Byrne September 23rd, 2010 @ 08:06 PM
Since this is still present in 2.3.9 and this ticket is still classed as 'new' am I to conclude that it is not yet fixed in 3.0.0? If so, what is preventing this issue from being fixed in a standard release.
-
Jeremy Kemper September 23rd, 2010 @ 10:01 PM
- Milestone set to 2.3.10
- State changed from new to open
- Assigned user set to Aaron Patterson
- Importance changed from to Low
-
Étienne Barrié September 24th, 2010 @ 01:44 AM
James, yes and no. It’s fixed in 3.0.0 and master (7a1bba4799f3fae2c3699816bc071128fd591461 and c0fa4de65b32fc5e8251dafab1330f044d682a1e), but only for add_index, and not for remove_index.
The original patch still applies (with offsets) on 2-3-stable, but you’ll need a slightly different patch (attached) for master and 3-0-stable.
-
Aaron Patterson September 27th, 2010 @ 06:44 PM
Hi Étienne, I've applied your patch for 2-3-stable. Can you rebase your patch for master / 3-0-stable, and I'll apply it? Currently, it doesn't apply.
-
Étienne Barrié September 27th, 2010 @ 08:06 PM
The problem this patch was solving (which I am responsible for :( ) was fixed in a few different commits for master / 3-0-stable. First add_index was fixed as I explained in my previous comment. And yesterday, remove_index was fixed too. (http://github.com/rails/rails/commit/d6f7b7d35337b87cc1c419e47fae52....
So basically now the patch for master is useless. But if you use the new attached patch anyway, you’ll get a test specific to symbolic index names, add_index will be again compatible to a long forgotten time where its third argument was "UNIQUE", and a tiny and totally useless performance improvement which is just here because that's the way I had coded the patch before the other patch rendered it useless :D
I think it's worth it for the test alone, for consistency with 2-3-stable.
-
Aaron Patterson September 28th, 2010 @ 06:08 PM
- State changed from open to committed
Étienne,
I agree. I
I've committed this patch. Thanks!
-
Andrea Campi October 16th, 2010 @ 11:52 PM
- Tag changed from rake db:migrate rails-2.3.8 bug, 3.0, patch to 2-3-stable, 3.0, migrations, patch
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>