mirror of
https://github.com/valitydev/psql-migration.git
synced 2024-11-06 01:05:18 +00:00
making setup idempotent
This commit is contained in:
parent
b48b6fb02d
commit
3268687828
@ -109,11 +109,11 @@ handle_command({ok, {Args, ["setup"]}}) ->
|
||||
{ok, Opts} = connection_opts(Args),
|
||||
case maps:take(database, Opts) of
|
||||
error ->
|
||||
handle_command_result({error, "No database to reset~n"});
|
||||
handle_command_result({error, "No database to set up~n"});
|
||||
{Database, Opts1} ->
|
||||
case with_connection(Opts1#{database => "postgres"},
|
||||
fun(Conn) ->
|
||||
if_ok(epgsql:squery(Conn, "create database \"" ++ Database ++ "\""))
|
||||
if_ok(epgsql:squery(Conn, "create database if not exists \"" ++ Database ++ "\""))
|
||||
end) of
|
||||
ok ->
|
||||
handle_command({ok, {Args, ["run"]}});
|
||||
|
Loading…
Reference in New Issue
Block a user