Skip to content

Commit 799db88

Browse files
committed
up
1 parent 4a73473 commit 799db88

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

lib/ecto/adapters/myxql.ex

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -416,18 +416,22 @@ defmodule Ecto.Adapters.MyXQL do
416416
def structure_load(default, config) do
417417
path = config[:dump_path] || Path.join(default, "structure.sql")
418418

419-
with {:ok, contents} <- File.read(path) do
420-
args = [
421-
"--execute",
422-
"SET FOREIGN_KEY_CHECKS = 0; " <> contents <> "; SET FOREIGN_KEY_CHECKS = 1",
423-
"--database",
424-
config[:database]
425-
]
426-
427-
case run_with_cmd("mysql", config, args) do
428-
{_output, 0} -> {:ok, path}
429-
{output, _} -> {:error, output}
430-
end
419+
case File.read(path) do
420+
{:ok, contents} ->
421+
args = [
422+
"--execute",
423+
"SET FOREIGN_KEY_CHECKS = 0; " <> contents <> "; SET FOREIGN_KEY_CHECKS = 1",
424+
"--database",
425+
config[:database]
426+
]
427+
428+
case run_with_cmd("mysql", config, args) do
429+
{_output, 0} -> {:ok, path}
430+
{output, _} -> {:error, output}
431+
end
432+
433+
{:error, reason} ->
434+
{:error, "could not read #{inspect(path)}: #{:file.format_error(reason)}"}
431435
end
432436
end
433437

0 commit comments

Comments
 (0)