aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration
diff options
context:
space:
mode:
authorMehmet Emin INAC <mehmetemininac@gmail.com>2018-09-22 16:47:57 +0200
committerMehmet Emin INAC <mehmetemininac@gmail.com>2018-09-22 16:47:57 +0200
commit5e4c22dfbb6dad676f74ded50b8c2536834a46a7 (patch)
tree2b6bd330ddeb2faa9848f84e33a72cfb50693011 /activerecord/test/cases/migration
parentd3b952184d8bdb6154aff1f8bc3eda58046026f6 (diff)
downloadrails-5e4c22dfbb6dad676f74ded50b8c2536834a46a7.tar.gz
rails-5e4c22dfbb6dad676f74ded50b8c2536834a46a7.tar.bz2
rails-5e4c22dfbb6dad676f74ded50b8c2536834a46a7.zip
Index option added for change_table migrations
In case if we want to add a column into the existing table with index on it, we have to add column and index in two seperate lines. With this feature we don't need to write an extra line to add index for column. We can just use `index` option. Old behaviour in action: ``` change_table(:languages) do |t| t.string :country_code t.index: :country_code end ``` New behaviour in action: ``` change_table(:languages) do |t| t.string :country_code, index: true end ``` Exactly same behaviour is already exist for `create_table` migrations.
Diffstat (limited to 'activerecord/test/cases/migration')
-rw-r--r--activerecord/test/cases/migration/change_table_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/change_table_test.rb b/activerecord/test/cases/migration/change_table_test.rb
index 034bf32165..c108d372d1 100644
--- a/activerecord/test/cases/migration/change_table_test.rb
+++ b/activerecord/test/cases/migration/change_table_test.rb
@@ -164,6 +164,14 @@ module ActiveRecord
end
end
+ def test_column_creates_column_with_index
+ with_change_table do |t|
+ @connection.expect :add_column, nil, [:delete_me, :bar, :integer, {}]
+ @connection.expect :add_index, nil, [:delete_me, :bar, {}]
+ t.column :bar, :integer, index: true
+ end
+ end
+
def test_index_creates_index
with_change_table do |t|
@connection.expect :add_index, nil, [:delete_me, :bar, {}]