@@ -274,6 +274,20 @@ defmodule Ecto.Migration do
274
274
275
275
config :app, App.Repo, migration_default_prefix: "my_prefix"
276
276
277
+ ## Collations
278
+
279
+ For columns with a text type, the collation can be set on the column with the
280
+ option `:collation`. This can be useful when relying on ASCII sorting of
281
+ characters when using a fractional index for example. All supported collations
282
+ are not known by `ecto_sql` and specifying an incorrect collation might cause
283
+ a migration to fail.
284
+
285
+ def change do
286
+ create table(:collate) do
287
+ add :string, :string, collation: "POSIX"
288
+ end
289
+ end
290
+
277
291
## Comments
278
292
279
293
Migrations where you create or alter a table support specifying table
@@ -1166,6 +1180,7 @@ defmodule Ecto.Migration do
1166
1180
specified.
1167
1181
* `:scale` - the scale of a numeric type. Defaults to `0`.
1168
1182
* `:comment` - adds a comment to the added column.
1183
+ * `:collation` - the collation of the text type.
1169
1184
* `:after` - positions field after the specified one. Only supported on MySQL,
1170
1185
it is ignored by other databases.
1171
1186
* `:generated` - a string representing the expression for a generated column. See
@@ -1345,6 +1360,7 @@ defmodule Ecto.Migration do
1345
1360
specified.
1346
1361
* `:scale` - the scale of a numeric type. Defaults to `0`.
1347
1362
* `:comment` - adds a comment to the modified column.
1363
+ * `:collation` - the collation of the text type.
1348
1364
"""
1349
1365
def modify ( column , type , opts \\ [ ] ) when is_atom ( column ) and is_list ( opts ) do
1350
1366
validate_precision_opts! ( opts , column )
0 commit comments