diff options
author | Yasuo Honda <yasuo.honda@gmail.com> | 2014-12-30 20:32:47 +0000 |
---|---|---|
committer | Yasuo Honda <yasuo.honda@gmail.com> | 2014-12-30 20:34:41 +0000 |
commit | c96acd18c05ea713cbc01fa41a80dfe43bcdeebb (patch) | |
tree | 1a301988e924d5b69bdc5d2746a1c11c1027b88e | |
parent | 322750e213ee929752a8bb07dbe44b839452e0a3 (diff) | |
download | rails-c96acd18c05ea713cbc01fa41a80dfe43bcdeebb.tar.gz rails-c96acd18c05ea713cbc01fa41a80dfe43bcdeebb.tar.bz2 rails-c96acd18c05ea713cbc01fa41a80dfe43bcdeebb.zip |
Raise a better exception for renaming long indexes for mysql adapters
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index a3c124bae6..92b4322843 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -499,6 +499,9 @@ module ActiveRecord def rename_index(table_name, old_name, new_name) if supports_rename_index? + if new_name.length > allowed_index_name_length + raise ArgumentError, "Index name '#{new_name}' on table '#{table_name}' is too long; the limit is #{allowed_index_name_length} characters" + end execute "ALTER TABLE #{quote_table_name(table_name)} RENAME INDEX #{quote_table_name(old_name)} TO #{quote_table_name(new_name)}" else super |