@@ -463,6 +463,21 @@ defmodule Ecto.Integration.MigrationTest do
463
463
end
464
464
end
465
465
466
+
467
+ defmodule CollateMigration do
468
+ use Ecto.Migration
469
+
470
+ def change do
471
+ create table ( :collate ) do
472
+ add :string , :string , collation: "POSIX"
473
+ add :char , :char , collation: "POSIX"
474
+ add :varchar , :varchar , collation: "POSIX"
475
+ add :text , :text , collation: "POSIX"
476
+ add :integer , :integer , collation: "POSIX"
477
+ end
478
+ end
479
+ end
480
+
466
481
import Ecto.Query , only: [ from: 2 ]
467
482
import Ecto.Migrator , only: [ up: 4 , down: 4 ]
468
483
@@ -683,4 +698,30 @@ defmodule Ecto.Integration.MigrationTest do
683
698
684
699
:ok = down ( PoolRepo , num , OnDeleteNilifyColumnsMigration , log: false )
685
700
end
701
+
702
+ @ tag :add_column
703
+ test "collate can set on a column" , % { migration_number: num } do
704
+ assert :ok = up ( PoolRepo , num , CollateMigration , log: true )
705
+ query = fn column -> """
706
+ SELECT column_name, data_type, collation_name
707
+ FROM information_schema.columns
708
+ WHERE table_name = 'collate' AND column_name = '#{ column } ';
709
+ """
710
+ end
711
+ for type <- ~w/ string varchar/ do
712
+ assert % {
713
+ rows: [ [ ^ type , "character varying" , "POSIX" ] ]
714
+ } = Ecto.Adapters.SQL . query! ( PoolRepo , query . ( type ) , [ ] )
715
+ end
716
+ assert % {
717
+ rows: [ [ "char" , "character" , "POSIX" ] ]
718
+ } = Ecto.Adapters.SQL . query! ( PoolRepo , query . ( "char" ) , [ ] )
719
+
720
+ assert % {
721
+ rows: [ [ "text" , "text" , "POSIX" ] ]
722
+ } = Ecto.Adapters.SQL . query! ( PoolRepo , query . ( "text" ) , [ ] )
723
+ assert % {
724
+ rows: [ [ "integer" , "integer" , nil ] ]
725
+ } = Ecto.Adapters.SQL . query! ( PoolRepo , query . ( "integer" ) , [ ] )
726
+ end
686
727
end
0 commit comments