Permalink
Browse files

Merge pull request #13038 from ccutrer/mysql_rename_index

implement rename_index natively for MySQL > 5.7
  • Loading branch information...
2 parents 0ff2d26 + a9771dd commit cca71659b7027c7206749f2e35e8a235033fe287 @senny senny committed Nov 28, 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 cca7165

Please sign in to comment.