提交 9477f437 编写于 作者: M Mauro George

Create Changing Columns on migrations guides

[ci skip]
上级 3051356a
......@@ -415,6 +415,28 @@ end
removes the `description` and `name` columns, creates a `part_number` string
column and adds an index on it. Finally it renames the `upccode` column.
### Changing Columns
Like the `remove_column` and `add_column` Rails provides the `change_column`.
```ruby
change_column :products, :part_number, :text
```
This changes the column part_number on products table to be a text.
Besides the `change_column`, the `change_column_null` and
`change_column_default` are used specifically to change the null and default
values of a column.
```ruby
change_column_null :products, :name, false
change_column_default :products, :approved, false
```
This sets name on products to a NOT NULL column and the default value
of approved as false.
### When Helpers aren't Enough
If the helpers provided by Active Record aren't enough you can use the `execute`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册