respect auto_increment in rename_column for mysql #9928

Merged
merged 1 commit into from Mar 26, 2013

Conversation

Projects
None yet
3 participants
Member

vipulnsward commented Mar 25, 2013

Closes #3493

The PR extracts "extra" on mysql column to fetch auto_increment information, which is associated with the column.

This information is then used when migrating.

Member

vipulnsward commented Mar 25, 2013

@rafaelfranca , @carlosantoniodasilva : could you take a look at this?

activerecord/test/cases/migration/columns_test.rb
@@ -62,6 +62,13 @@ def test_rename_column_preserves_default_value_not_null
assert_equal 70000, default_after
end
+ def test_mysql_rename_column_preserves_auto_increment
+ if current_adapter?(:MysqlAdapter, :Mysql2Adapter)
@carlosantoniodasilva

carlosantoniodasilva Mar 25, 2013

Owner

The if check could go outside the test.

activerecord/test/cases/migration/columns_test.rb
+ def test_mysql_rename_column_preserves_auto_increment
+ if current_adapter?(:MysqlAdapter, :Mysql2Adapter)
+ rename_column "test_models", "id", "id_test"
+ assert_equal connection.columns("test_models").find { |c| c.name == "id_test" }.extra , "auto_increment"
@carlosantoniodasilva

carlosantoniodasilva Mar 25, 2013

Owner

I think the args should be inverted.

@@ -63,8 +63,8 @@ def each_hash(result) # :nodoc:
end
end
- def new_column(field, default, type, null, collation) # :nodoc:
- Column.new(field, default, type, null, collation, strict_mode?)
+ def new_column(field, default, type, null, collation, extra = "") # :nodoc:
@carlosantoniodasilva

carlosantoniodasilva Mar 25, 2013

Owner

Should these extra args be nil by default instead? Or should they have a default?

@vipulnsward

vipulnsward Mar 26, 2013

Member

extras default to "" instead of NULL in mysql, so the empty string

Member

vipulnsward commented Mar 26, 2013

fixed/rebased

Owner

rafaelfranca commented Mar 26, 2013

@vipulnsward could you add a CHANGELOG entry?

@ghost ghost assigned rafaelfranca Mar 26, 2013

Member

vipulnsward commented Mar 26, 2013

@rafaelfranca Added.

rafaelfranca added a commit that referenced this pull request Mar 26, 2013

Merge pull request #9928 from vipulnsward/fix_rename_auto_increment_m…
…ysql

respect auto_increment in rename_column for mysql

@rafaelfranca rafaelfranca merged commit 1707763 into rails:master Mar 26, 2013

@vipulnsward vipulnsward deleted the vipulnsward:fix_rename_auto_increment_mysql branch Mar 26, 2013

Member

vipulnsward commented Mar 26, 2013

@rafaelfranca thanks.

Owner

rafaelfranca commented Mar 26, 2013

Thank you!!

Rafael Mendonça França
http://twitter.com/rafaelfranca
https://github.com/rafaelfranca

On Tue, Mar 26, 2013 at 4:00 PM, Vipul A M notifications@github.com wrote:

@rafaelfranca https://github.com/rafaelfranca thanks.


Reply to this email directly or view it on GitHubhttps://github.com/rails/rails/pull/9928#issuecomment-15480563
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment