提交 1a782b2b 编写于 作者: J Jarek Radosz

Add rename_index to change_table.

上级 e21579f1
## Rails 4.0.0 (unreleased) ##
* `rename_index` can be used inside a `change_table` block.
change_table :accounts do |t|
t.rename_index :user_id, :account_id
end
*Jarek Radosz*
* `#pluck` can be used on a relation with `select` clause. Fix #7551
Example:
......
......@@ -324,6 +324,7 @@ def native
# change_table :table do |t|
# t.column
# t.index
# t.rename_index
# t.timestamps
# t.change
# t.change_default
......@@ -386,6 +387,13 @@ def index_exists?(column_name, options = {})
@base.index_exists?(@table_name, column_name, options)
end
# Renames the given index on the table.
#
# t.rename_index(:user_id, :account_id)
def rename_index(index_name, new_index_name)
@base.rename_index(@table_name, index_name, new_index_name)
end
# Adds timestamps (+created_at+ and +updated_at+) columns to the table. See SchemaStatements#add_timestamps
#
# t.timestamps
......
......@@ -164,6 +164,13 @@ def test_index_exists_with_options
end
end
def test_rename_index_renames_index
with_change_table do |t|
@connection.expect :rename_index, nil, [:delete_me, :bar, :baz]
t.rename_index :bar, :baz
end
end
def test_change_changes_column
with_change_table do |t|
@connection.expect :change_column, nil, [:delete_me, :bar, :string, {}]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册