mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
promotes change_column_null to the migrations API
This commit is contained in:
parent
efa5307f18
commit
cae93be0ca
2 changed files with 27 additions and 0 deletions
|
@ -1,5 +1,12 @@
|
|||
## Rails 4.0.0 (unreleased) ##
|
||||
|
||||
* Promotes `change_column_null` to the migrations API. This macro sets/removes
|
||||
`NOT NULL` constraints, and accepts an optional argument to replace existing
|
||||
`NULL`s if needed. The adapters for SQLite, MySQL, PostgreSQL, and (at least)
|
||||
Oracle, already implement this method.
|
||||
|
||||
*Xavier Noria*
|
||||
|
||||
* Uniqueness validation allows you to pass `:conditions` to limit
|
||||
the constraint lookup.
|
||||
|
||||
|
|
|
@ -402,6 +402,26 @@ module ActiveRecord
|
|||
raise NotImplementedError, "change_column_default is not implemented"
|
||||
end
|
||||
|
||||
# Sets or removes a +NOT NULL+ constraint on a column. The +null+ flag
|
||||
# indicates wheter the value can be +NULL+. For example
|
||||
#
|
||||
# change_column_null(:users, :nickname, false)
|
||||
#
|
||||
# says nicknames cannot be +NULL+ (adds the constraint), whereas
|
||||
#
|
||||
# change_column_null(:users, :nickname, true)
|
||||
#
|
||||
# allows them to be +NULL+ (drops the constraint).
|
||||
#
|
||||
# The method accepts an optional fourth argument to replace existing
|
||||
# +NULL+s with some other value. Use that one when enabling the
|
||||
# constraint if needed, since otherwise those rows would not be valid.
|
||||
#
|
||||
# Please note the fourth argument does not set a column's default.
|
||||
def change_column_null(table_name, column_name, null, default = nil)
|
||||
raise NotImplementedError, "change_column_null is not implemented"
|
||||
end
|
||||
|
||||
# Renames a column.
|
||||
#
|
||||
# rename_column(:suppliers, :description, :name)
|
||||
|
|
Loading…
Reference in a new issue