This project is archived and is in readonly mode.
ActiveRecord::ConnectionAdapters::Table#index does not generat indexes
Reported by Jarl Friis | March 3rd, 2010 @ 08:50 PM
Hi.
When using the following syntax for creating indexes in a migration, no indexes are created:
create_table :properties do |t|
t.string :namespace
t.string :name
t.string :value
t.index [:namespace, :name], :unique => true
end
However when I use
create_table :properties do |t|
t.string :namespace
t.string :name
t.string :value
end
add_index :properties, [:namespace, :name], :unique => true
Things work fine.
This has been reproduced on both PostgreSQL and MySQL adapter.
Please
see
http://groups.google.com/group/rubyonrails-talk/msg/e5b9a1fad6ccf79c
for the discussion and confirmation.
Jarl
Comments and changes to this ticket
-
Jarl Friis March 3rd, 2010 @ 08:52 PM
- Tag changed from add_index migration, index to add_index, index, migration
I forgot to mention, it has been seen in Rails 2.3.5 for both PostgreSQL and MySQL adapter.
-
Deleted User March 3rd, 2010 @ 11:30 PM
I've reproduced the same behavior on rails 3.0.0.beta and MySQL.
-
Philip Hallstrom March 4th, 2010 @ 04:35 PM
The following applies to Rails 2.3.5....
This got me interested so I started to write up a patch and when
digging around in the source some more noticed that the only places
"t.index" is referenced is when referring to change_table() NOT create_table().See line 533 of rails/activerecord/lib/active_record/
connection_adapters/abstract/schema_definitions.rbI compared this with the create_table stuff and there is a clear
distinction.So, I am thinking now that this isn't a bug, but perhaps is an over
sight that should be addressed so the two are more inline. But then
again there is a bunch of other stuff in the change_table() that isn't
in create_table.Not sure how/if this helps, but perhaps it provides more background.
-
Jarl Friis August 30th, 2010 @ 01:51 PM
I observe (still in 2.3.5) that
change_table
also suffers this problem. The below code will have no effect.change_table :properties do |t| t.index [:namespace, :name], :unique => true end
But
#remove_index
(in the self.down method) works! E.g. the below code has effect.change_table :properties do |t| t.remove_index [:namespace, :name] end
-
Santiago Pastorino February 2nd, 2011 @ 04:49 PM
- State changed from new to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino February 2nd, 2011 @ 04:49 PM
- State changed from open to stale
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>