Skip to content

Commit 849a417

Browse files
committed
don't fail MySQL 5.x constraint tests
1 parent 2d3173e commit 849a417

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

integration_test/myxql/constraints_test.exs

+15-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ defmodule Ecto.Integration.ConstraintsTest do
2727
defp strip_source(name, source), do: String.trim_leading(name, "#{source}.")
2828
end
2929

30-
defmodule ConstraintMigration do
30+
defmodule ConstraintTableMigration do
3131
use Ecto.Migration
3232

3333
@table table(:constraints_test)
@@ -38,7 +38,15 @@ defmodule Ecto.Integration.ConstraintsTest do
3838
add :from, :integer
3939
add :to, :integer
4040
end
41+
end
42+
end
43+
44+
defmodule ConstraintMigration do
45+
use Ecto.Migration
4146

47+
@table table(:constraints_test)
48+
49+
def change do
4250
# Only valid after MySQL 8.0.19
4351
create constraint(@table.name, :positive_price, check: "price > 0")
4452
end
@@ -113,7 +121,7 @@ defmodule Ecto.Integration.ConstraintsTest do
113121
setup_all do
114122
ExUnit.CaptureLog.capture_log(fn ->
115123
num = @base_migration + System.unique_integer([:positive])
116-
up(PoolRepo, num, ConstraintMigration, log: false)
124+
up(PoolRepo, num, ConstraintTableMigration, log: false)
117125
up(PoolRepo, num + 1, ProcedureEmulatingConstraintMigration, log: false)
118126
end)
119127

@@ -122,6 +130,11 @@ defmodule Ecto.Integration.ConstraintsTest do
122130

123131
@tag :create_constraint
124132
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+
125138
# When the changeset doesn't expect the db error
126139
changeset = Ecto.Changeset.change(%Constraint{}, price: -10)
127140

0 commit comments

Comments
 (0)