@@ -27,7 +27,7 @@ defmodule Ecto.Integration.ConstraintsTest do
27
27
defp strip_source ( name , source ) , do: String . trim_leading ( name , "#{ source } ." )
28
28
end
29
29
30
- defmodule ConstraintMigration do
30
+ defmodule ConstraintTableMigration do
31
31
use Ecto.Migration
32
32
33
33
@ table table ( :constraints_test )
@@ -38,7 +38,15 @@ defmodule Ecto.Integration.ConstraintsTest do
38
38
add :from , :integer
39
39
add :to , :integer
40
40
end
41
+ end
42
+ end
43
+
44
+ defmodule ConstraintMigration do
45
+ use Ecto.Migration
41
46
47
+ @ table table ( :constraints_test )
48
+
49
+ def change do
42
50
# Only valid after MySQL 8.0.19
43
51
create constraint ( @ table . name , :positive_price , check: "price > 0" )
44
52
end
@@ -113,7 +121,7 @@ defmodule Ecto.Integration.ConstraintsTest do
113
121
setup_all do
114
122
ExUnit.CaptureLog . capture_log ( fn ->
115
123
num = @ base_migration + System . unique_integer ( [ :positive ] )
116
- up ( PoolRepo , num , ConstraintMigration , log: false )
124
+ up ( PoolRepo , num , ConstraintTableMigration , log: false )
117
125
up ( PoolRepo , num + 1 , ProcedureEmulatingConstraintMigration , log: false )
118
126
end )
119
127
@@ -122,6 +130,11 @@ defmodule Ecto.Integration.ConstraintsTest do
122
130
123
131
@ tag :create_constraint
124
132
test "check constraint" do
133
+ num = @ base_migration + System . unique_integer ( [ :positive ] )
134
+ ExUnit.CaptureLog . capture_log ( fn ->
135
+ :ok = up ( PoolRepo , num , ConstraintMigration , log: false )
136
+ end )
137
+
125
138
# When the changeset doesn't expect the db error
126
139
changeset = Ecto.Changeset . change ( % Constraint { } , price: - 10 )
127
140
0 commit comments