Merge pull request #13 from davidszkiba/new-migration-failed-message

Show error if migration can not be created
This commit is contained in:
Marc Nijdam 2022-12-02 16:28:54 -05:00 committed by GitHub
commit c84b06fc7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,8 +65,12 @@ handle_command({ok, {Args, ["new", Name]}}) ->
"-- :down\n", "-- :down\n",
"-- Down migration\n" "-- Down migration\n"
], ],
file:write_file(Filename, list_to_binary(C), [exclusive]), Result = case file:write_file(Filename, list_to_binary(C), [exclusive]) of
handle_command_result({ok, "Created migration: ~s~n", [Filename]}); ok -> {ok, "Created migration: ~s~n", [Filename]};
{error, Reason} -> {error,
"Migration can not be written to file ~s: ~s~n", [Filename, Reason]}
end,
handle_command_result(Result);
handle_command({ok, {Args, ["run"]}}) -> handle_command({ok, {Args, ["run"]}}) ->
Available = available_migrations(Args), Available = available_migrations(Args),
Result = with_connection( Result = with_connection(