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:
parent
258e9adc05
commit
51852d2eb5
3 changed files with 12 additions and 2 deletions
|
@ -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*
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue