From b6226c3cfb0344e8973c92bddf8276ff1d26cd08 Mon Sep 17 00:00:00 2001 From: Ezekiel Smithburg Date: Thu, 10 Jan 2013 00:50:52 -0800 Subject: 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. --- .../active_record/connection_adapters/abstract/schema_statements.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/lib/active_record/connection_adapters/abstract') 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 -- cgit v1.2.3