Skip to content

Instantly share code, notes, and snippets.

@rlopzc
Created February 25, 2023 14:16
Show Gist options
  • Save rlopzc/101a677eac367165bd98bba356075c56 to your computer and use it in GitHub Desktop.
Save rlopzc/101a677eac367165bd98bba356075c56 to your computer and use it in GitHub Desktop.
Log SQL commands in migration
defmodule MyApp.Release do
# Log SQL commands generated by migrations.
# More info here https://hexdocs.pm/ecto_sql/Ecto.Migrator.html#up/4-options
@migrator_default_opts [log_migrations_sql: :info]
...
def migrate(opts \\ [all: true]) do
load_app()
opts = @migrator_default_opts ++ opts
for repo <- repos() do
{:ok, _fun_return, _apps} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, opts))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment