Created
February 25, 2023 14:16
-
-
Save rlopzc/101a677eac367165bd98bba356075c56 to your computer and use it in GitHub Desktop.
Log SQL commands in migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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