Bug: logidze_logger_after created incorrectly on --update
ERROR (on db:rollback):
-- drop_function(:logidze_logger_after, {version: 5})
bin/rails aborted!
StandardError: An error has occurred, this and all later migrations canceled: (StandardError)
wrong number of arguments (given 2, expected 1)
Caused by:
ArgumentError: wrong number of arguments (given 2, expected 1) (ArgumentError)
Tasks: TOP => db:rollback
CONTEXT:
I ran rails generate logidze:install --update, and it generated the following migration (yes, including the extra whitespaces):
class LogidzeUpdate141 < ActiveRecord::Migration[7.2]
def change
reversible do |dir|
dir.up do
create_function :logidze_logger, version: 5
end
dir.down do
create_function :logidze_logger, version: 2
end
end
create_function :logidze_logger_after, version: 5
end
end
Issues observed
- Rollback fails because
drop_function(:logidze_logger_after, { version: 5 })is invoked with two arguments, but looks like the adapter expects a single argument. Removingversion: 5allows rollback to succeed, but not sure if that's the intended behavior. - Questionable generation of logidze_logger_after: the
logidze_logger_afterfunction appears to be generated even without passing an "after-trigger" flag. Is this intended for--update? - Excessive whitespace: the generated migration includes multiple unnecessary blank lines.
FWIW, I ran bundle update logidze before so gem was up to date.
the logidze_logger_after function appears to be generated even without passing an "after-trigger" flag. Is this intended for --update?
Yes. We generate all the functions on install/update, so you can enable any feature later.
because drop_function(:logidze_logger_after, { version: 5 }) is invoked with two arguments
That looks like an fx bug; create_function is supposed to be invertible. Do you use the latest version of fx?
the generated migration includes multiple unnecessary blank lines.
I know 😁 Currently, we assume that you run RuboCop/Standard after generation (you're still likely to do so even without blank lines).