Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #9389 from senny/forwardport_9388

Forwardport #9388 rename/remove column preserves custom PK.
  • Loading branch information...
commit 23048551fdb679e694d8245e9f8c969ed7a71f40 2 parents cad397e + d03928c
Carlos Antonio da Silva carlosantoniodasilva authored
16 ...record/test/cases/migration/rename_column_test.rb → activerecord/test/cases/migration/columns_test.rb
View
@@ -128,7 +128,7 @@ def test_remove_column_with_multi_column_index
assert_equal 1, connection.indexes('test_models').size
remove_column("test_models", "hat_size")
- # Every database and/or database adapter has their own behavior
+ # Every database and/or database adapter has their own behavior
# if it drops the multi-column index when any of the indexed columns dropped by remove_column.
if current_adapter?(:PostgreSQLAdapter, :OracleAdapter)
assert_equal [], connection.indexes('test_models').map(&:name)
@@ -245,6 +245,20 @@ def test_change_column_default_to_null
def test_remove_column_no_second_parameter_raises_exception
assert_raise(ArgumentError) { connection.remove_column("funny") }
end
+
+ def test_removing_and_renaming_column_preserves_custom_primary_key
+ connection.create_table "my_table", primary_key: "my_table_id", force: true do |t|
+ t.integer "col_one"
+ t.string "col_two", limit: 128, null: false
+ end
+
+ remove_column("my_table", "col_two")
+ rename_column("my_table", "col_one", "col_three")
+
+ assert_equal 'my_table_id', connection.primary_key('my_table')
+ ensure
+ connection.drop_table(:my_table) rescue nil
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.