fuelen / ecto_dev_logger

An alternative logger for Ecto queries
Apache License 2.0
147 stars 14 forks source link

Pending migration check SQL gets logged on every request in development #14

Closed vanderhoop closed 1 year ago

vanderhoop commented 1 year ago

Hello, and thanks again for a great library.

I've just noticed that the 'pending migration check' SQL (example below) is logged before every request in my Phoenix app (in development), which adds quite a bit of unnecessary noise to the logs.

[debug] QUERY OK db=0.2ms
begin
[debug] QUERY OK db=0.1ms
LOCK TABLE "schema_migrations" IN SHARE UPDATE EXCLUSIVE MODE
[debug] QUERY OK source="schema_migrations" db=0.3ms
SELECT s0."version"::bigint FROM "schema_migrations" AS s0
↳ anonymous fn/5 in Ecto.Migrator.lock_for_migrations/4, at: lib/ecto/migrator.ex:533
[debug] QUERY OK db=0.2ms
commit

I wondered if this was some sort of configuration issue in my particular app, but I was able to reproduce in a new phoenix app with ecto_dev_logger installed/configured.

The reproduction repo can be found at https://github.com/vanderhoop/reproduction_of_schema_migrator_sql_logging_issue

fuelen commented 1 year ago

Hi @vanderhoop

The issue was raised here https://github.com/phoenixframework/phoenix_ecto/issues/152 And we have a fix for this here https://github.com/fuelen/ecto_dev_logger/commit/56f3114c28e0bd3b3863e069a35507e7cce268a0 You have to use newer version of ecto_sql package.

vanderhoop commented 1 year ago

Gotcha, and thanks for the quick response.

For anyone else coming here with this issue, note that the change needed in ecto_sql hasn't been released as of today. Based on the changelog, it'll be a part of 3.9 once that's released.

fuelen commented 1 year ago

https://github.com/elixir-ecto/ecto_sql/commit/1dfbf29e818793609dc3be3f564f6362791cdb2f released 2 hours ago