Skip to content

Commit

Permalink
Don't print error message if there is no extra triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
ponychicken authored Aug 22, 2024
1 parent ef4eb19 commit 8553daa
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions lib/ecto_watch/watcher_trigger_validator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,40 @@ defmodule EctoWatch.WatcherTriggerValidator do
Enum.each(extra_found_triggers, &drop_trigger(repo_mod, &1))
Enum.each(extra_found_functions, &drop_function(repo_mod, &1))
else
Logger.error("""
Found the following extra EctoWatch triggers:
if MapSet.size(extra_found_triggers) > 0 do
log_extra_triggers(extra_found_triggers)
end
if MapSet.size(extra_found_functions) > 0 do
log_extra_functions(extra_found_functions)
end
end
end)

#{Enum.map_join(extra_found_triggers, "\n", fn trigger_details -> "\"#{trigger_details.name}\" in the table \"#{trigger_details.table_schema}\".\"#{trigger_details.table_name}\"" end)}
:ok
end

...but they were not specified in the watcher options.
defp log_extra_triggers(extra_found_triggers) do
Logger.error("""
Found the following extra EctoWatch triggers:
To cleanup unspecified triggers and functions, run your app with the `ECTO_WATCH_CLEANUP`
environment variable set to the value `cleanup`
""")
#{Enum.map_join(extra_found_triggers, "\n", fn trigger_details -> "\"#{trigger_details.name}\" in the table \"#{trigger_details.table_schema}\".\"#{trigger_details.table_name}\"" end)}
Logger.error("""
Found the following extra EctoWatch functions:
...but they were not specified in the watcher options.
#{Enum.map_join(extra_found_functions, "\n", fn function_details -> "\"#{function_details.name}\" in the schema \"#{function_details.schema}\"" end)}
To cleanup unspecified triggers and functions, run your app with the `ECTO_WATCH_CLEANUP`
environment variable set to the value `cleanup`
""")
end

To cleanup unspecified triggers and functions, run your app with the `ECTO_WATCH_CLEANUP`
environment variable set to the value `cleanup`
""")
end
end)
defp log_extra_functions(extra_found_functions) do
Logger.error("""
Found the following extra EctoWatch functions:
:ok
#{Enum.map_join(extra_found_functions, "\n", fn function_details -> "\"#{function_details.name}\" in the schema \"#{function_details.schema}\"" end)}
To cleanup unspecified triggers and functions, run your app with the `ECTO_WATCH_CLEANUP`
environment variable set to the value `cleanup`
""")
end

defp triggers_by_repo_mod do
Expand Down

0 comments on commit 8553daa

Please sign in to comment.