diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-30 21:13:39 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-30 21:13:39 -0300 |
commit | 3d51da3964583193be6421717a2f3bfd917fbb91 (patch) | |
tree | e0e2ce18625a0acf25bbb8f1cee7cc95a34fc7aa /activerecord | |
parent | 0d1ab3491522a6b757e864412c84406764f10b9d (diff) | |
parent | c96acd18c05ea713cbc01fa41a80dfe43bcdeebb (diff) | |
download | rails-3d51da3964583193be6421717a2f3bfd917fbb91.tar.gz rails-3d51da3964583193be6421717a2f3bfd917fbb91.tar.bz2 rails-3d51da3964583193be6421717a2f3bfd917fbb91.zip |
Merge pull request #18264 from yahonda/rename_index_mysql
Raise a better exception for renaming long indexes for mysql adapters
Diffstat (limited to 'activerecord')
-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 |