Skip to content

Commit

Permalink
Use rpc to execute migrations.
Browse files Browse the repository at this point in the history
  • Loading branch information
bharendt committed Jul 14, 2015
1 parent ec50dff commit ee3b950
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/edeliver.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ defmodule Edeliver do
end)
end

def migrate(application_name, application_version, direction, migration_version \\ :all) do
direction = String.to_atom direction
def migrate(application_name, application_version, direction, migration_version \\ :all) when is_atom(direction) do
options = if migration_version == :all, do: [all: true], else: [to: to_string(migration_version)]
Ecto.Migrator.run(ecto_repository!, migrations_dir(application_name, application_version), direction, options)
end
Expand Down
7 changes: 7 additions & 0 deletions strategies/erlang-node-execute
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ run() {
NODE_ACTION="rpc Elixir.Edeliver run_command '[[list_pending_migrations, \"$APP\"]].'"
elif [[ "$NODE_ACTION" = migrations ]] && [[ "$RELEASE_CMD" != "mix" ]]; then
error "Showing migrations is only supported when using mix as release command."
elif [[ "$NODE_ACTION" = migrate ]] && [[ "$RELEASE_CMD" = "mix" ]]; then
local __up_or_down="up"
for args in $ARGS; do [[ "$arg" = "down" ]] && local __up_or_down="down"; done
[[ -n "$VERSION" ]] && local __to_version=", \"$VERSION\"" || local __to_version=""
NODE_ACTION="rpc Elixir.Edeliver run_command '[[migrate, \"$APP\", ${__up_or_down}${__to_version}]].'"
elif [[ "$NODE_ACTION" = migrate ]] && [[ "$RELEASE_CMD" != "mix" ]]; then
error "Executing migrations is only supported when using mix as release command."
fi
__exec_if_defined execute_custom_node_command "$NODE_ACTION" || execute_node_command "$NODE_ACTION"
}
Expand Down

0 comments on commit ee3b950

Please sign in to comment.