提交 c22cad96 编写于 作者: I Islam Taha

Preserve column comment on renaming column

Update activerecord changelog

Specify DB name in changelog and fix typo
上级 d5a3b2e4
* Preserve column comment value on changing column name on MySQL.
*Islam Taha*
* Add support for `if_exists` option for removing an index.
The `remove_index` method can take an `if_exists` option. If this is set to true an error won't be raised if the index doesn't exist.
......
......@@ -665,7 +665,8 @@ def rename_column_for_alter(table_name, column_name, new_column_name)
options = {
default: column.default,
null: column.null,
auto_increment: column.auto_increment?
auto_increment: column.auto_increment?,
comment: column.comment
}
current_type = exec_query("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE #{quote(column_name)}", "SCHEMA").first["Type"]
......
......@@ -114,6 +114,17 @@ def test_remove_comment_from_column
assert_nil column.comment
end
def test_rename_column_preserves_comment
@connection.add_column :commenteds, :rating, :string, comment: "I am running out of imagination"
@connection.rename_column :commenteds, :rating, :new_rating
Commented.reset_column_information
column = Commented.columns_hash["new_rating"]
assert_equal :string, column.type
assert_equal column.comment, "I am running out of imagination"
end
def test_schema_dump_with_comments
# Do all the stuff from other tests
@connection.add_column :commenteds, :rating, :integer, comment: "I am running out of imagination"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册