@@ -18,7 +18,8 @@ defmodule Mix.Tasks.Ecto.Migrate do
1818 prefix: :string ,
1919 pool_size: :integer ,
2020 log_sql: :boolean ,
21- log_sql_mode: :string ,
21+ log_migrations_sql: :boolean ,
22+ log_migrator_sql: :boolean ,
2223 strict_version_order: :boolean ,
2324 repo: [ :keep , :string ] ,
2425 no_compile: :boolean ,
@@ -71,11 +72,10 @@ defmodule Mix.Tasks.Ecto.Migrate do
7172
7273 * `--all` - run all pending migrations
7374
74- * `--log-sql` - log the underlying sql statements for migrations
75+ * `--log-migrations- sql` - log SQL generated by migration commands
7576
76- * `--log-sql-mode` - how much SQL to log. `"migrations"` logs only the SQL
77- from commands in the migrations. `"all"` also includes transactions, table
78- locks, and so on. Defaults to `"migrations"`.
77+ * `--log-migrator-sql` - log SQL generated by the migrator, such as
78+ transactions, table locks, etc
7979
8080 * `--migrations-path` - the path to load the migrations from, defaults to
8181 `"priv/repo/migrations"`. This option may be given multiple times in which
@@ -114,8 +114,10 @@ defmodule Mix.Tasks.Ecto.Migrate do
114114 do: opts ,
115115 else: Keyword . put ( opts , :all , true )
116116
117- validate_log_sql_mode! ( opts )
118- opts = conform_log_options ( opts )
117+ opts =
118+ if opts [ :quiet ] ,
119+ do: Keyword . merge ( opts , [ log: false , log_migrations_sql: false , log_migrator_sql: false ] ) ,
120+ else: opts
119121
120122 # Start ecto_sql explicitly before as we don't need
121123 # to restart those apps if migrated.
@@ -141,35 +143,4 @@ defmodule Mix.Tasks.Ecto.Migrate do
141143
142144 :ok
143145 end
144-
145- @ doc false
146- def validate_log_sql_mode! ( opts ) do
147- case Keyword . get ( opts , :log_sql_mode ) do
148- nil -> :ok
149- "migrations" -> :ok
150- "all" -> :ok
151- mode ->
152- Mix . raise ( """
153- #{ inspect ( mode ) } is not a valid log_sql_mode.
154- Valid options are: "all", "migrations"
155- """ )
156- end
157- end
158-
159- @ doc false
160- def conform_log_options ( opts ) do
161- opts =
162- if opts [ :log_sql_mode ] == "all" ,
163- do: Keyword . merge ( opts , [ log_migrations_sql: :info , log_migrator_sql: :info , log: :info ] ) ,
164- else: opts
165-
166- opts =
167- if opts [ :log_sql_mode ] == "migrations" ,
168- do: Keyword . merge ( opts , [ log_migrations_sql: :info , log: :info ] ) ,
169- else: opts
170-
171- if opts [ :quiet ] ,
172- do: Keyword . merge ( opts , [ log: false ] ) ,
173- else: opts
174- end
175146end
0 commit comments