1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix change_column_comment to preserve column's AUTO_INCREMENT in the MySQL adapter

This commit is contained in:
fatkodima 2022-02-18 19:59:06 +02:00
parent 258e9adc05
commit 51852d2eb5
3 changed files with 12 additions and 2 deletions

View file

@ -9,6 +9,10 @@
*Nick Holden*
* Fix `change_column_comment` to preserve column's AUTO_INCREMENT in the MySQL adapter
*fatkodima*
* Fix quoting of `ActiveSupport::Duration` and `Rational` numbers in the MySQL adapter.
*Kevin McPhillips*

View file

@ -722,6 +722,8 @@ module ActiveRecord
options[:comment] = column.comment
end
options[:auto_increment] = column.auto_increment?
td = create_table_definition(table_name)
cd = td.new_column_definition(column.name, type, **options)
schema_creation.accept(ChangeColumnDefinition.new(cd, column.name))

View file

@ -178,9 +178,13 @@ if ActiveRecord::Base.connection.supports_comments?
end
def test_change_column_comment
@connection.change_column_comment :commenteds, :name, "Edited column comment"
column = Commented.columns_hash["name"]
@connection.change_column_comment :commenteds, :id, "Edited column comment"
column = Commented.columns_hash["id"]
assert_equal "Edited column comment", column.comment
if current_adapter?(:Mysql2Adapter)
assert column.auto_increment?
end
end
def test_change_column_comment_to_nil