@@ -1035,10 +1035,12 @@ defmodule Ecto.Migration do
10351035 Modifies the type of a column when altering a table.
10361036
10371037 This command is not reversible unless the `:from` option is provided.
1038- If the `:from` value is a `%Reference{}` , the adapter will try to drop
1038+ When the `:from` option is set , the adapter will try to drop
10391039 the corresponding foreign key constraints before modifying the type.
1040- Note `:from` cannot be used to modify primary keys, as those are
1041- generally trickier to make reversible.
1040+ Generally speaking, you want to pass the type and each option
1041+ you are modifying to `:from`, so the column can be rolled back properly.
1042+ However, note that `:from` cannot be be used to modify primary keys,
1043+ as those are generally trickier to revert.
10421044
10431045 See `add/3` for more information on supported types.
10441046
@@ -1054,11 +1056,21 @@ defmodule Ecto.Migration do
10541056 modify :title, :text
10551057 end
10561058
1059+ # Self rollback when using the :from option
1060+ alter table("posts") do
1061+ modify :title, :text, from: :string
1062+ end
1063+
1064+ # Modify column with rollback options
1065+ alter table("posts") do
1066+ modify :title, :text, null: false, from: {:string, null: true}
1067+ end
1068+
10571069 ## Options
10581070
10591071 * `:null` - determines whether the column accepts null values.
10601072 * `:default` - changes the default value of the column.
1061- * `:from` - specifies the current type of the column.
1073+ * `:from` - specifies the current type and options of the column.
10621074 * `:size` - specifies the size of the type (for example, the number of characters).
10631075 The default is no size.
10641076 * `:precision` - the precision for a numeric type. Required when `:scale` is
0 commit comments