aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract
diff options
context:
space:
mode:
authorEzekiel Smithburg <tehgeekmeister@gmail.com>2013-01-10 00:50:52 -0800
committerEzekiel Smithburg <tehgeekmeister@gmail.com>2013-03-07 20:03:17 -0800
commitb6226c3cfb0344e8973c92bddf8276ff1d26cd08 (patch)
tree20dac789e99feec0b8b159f1443c57fec9ed6e2f /activerecord/lib/active_record/connection_adapters/abstract
parentb67043393b5ed6079989513299fe303ec3bc133b (diff)
downloadrails-b6226c3cfb0344e8973c92bddf8276ff1d26cd08.tar.gz
rails-b6226c3cfb0344e8973c92bddf8276ff1d26cd08.tar.bz2
rails-b6226c3cfb0344e8973c92bddf8276ff1d26cd08.zip
If an index can't be found by column, use the index name.
schema_statements uses the column name by default to construct the index name, and then raises an exception if it doesn't exist, even if the name option is specified, which causes #8858. this commit makes index_name_for_remove fall back to constructing the index name to remove based on the name option.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 5b8de184fe..9d624a6648 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -687,6 +687,12 @@ module ActiveRecord
index_name = index_name(table_name, options)
unless index_name_exists?(table_name, index_name, true)
+ if options.has_key? :name
+ options_without_column = options.dup
+ options_without_column.delete :column
+ index_name_without_column = index_name(table_name, options_without_column)
+ return index_name_without_column if index_name_exists?(table_name, index_name_without_column, false)
+ end
raise ArgumentError, "Index name '#{index_name}' on table '#{table_name}' does not exist"
end