Permalink
Browse files

implement rename_index natively for MySQL > 5.7

  • Loading branch information...
1 parent 598779b commit a9771ddba5fa75632b264af80f95ef463a882548 @ccutrer ccutrer committed Nov 25, 2013
@@ -1,3 +1,7 @@
+* Implement rename_index natively for MySQL > 5.7.
+
+ *Cody Cutrer*
+
* Fix bug when validating the uniqueness of an aliased attribute.
Fixes #12402.
@@ -487,6 +487,14 @@ def rename_table(table_name, new_name)
rename_table_indexes(table_name, new_name)
end
+ def rename_index(table_name, old_name, new_name)
+ if version[0] >= 5 && version[1] >= 7
+ execute "ALTER TABLE #{quote_table_name(table_name)} RENAME INDEX #{quote_table_name(old_name)} TO #{quote_table_name(new_name)}"
+ else
+ super
+ end
+ end
+
def change_column_default(table_name, column_name, default)
column = column_for(table_name, column_name)
change_column table_name, column_name, column.sql_type, :default => default

0 comments on commit a9771dd

Please sign in to comment.