1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-07 00:58:02 +00:00

Add Remove The Default Value On A Column as a rails til

This commit is contained in:
jbranchaud
2017-03-30 13:43:26 -05:00
parent a8222b1d4f
commit 1bfc1008a7
2 changed files with 18 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
# Remove The Default Value On A Column
You have a column on one of your database tables with a default value. You'd
like to remove the default value. Removing the default is the same as
setting it to `nil`. You can do this with the ActiveRecord DSL using the
`change_column_default` method.
```ruby
def change
change_column_default :users, :age, nil
end
```
See [the
docs](http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-change_column_default)
for more details.