class RuboCop::Cop::Rails::ReversibleMigrationMethodDefinition
end
end
# down migration
def down
end
# up migration
def up
class SomeMigration < ActiveRecord::Migration[6.0]
# good
end
end
# reversible migration
def change
class SomeMigration < ActiveRecord::Migration[6.0]
# good
end
end
# down migration
def down
# <—– missing up method
class SomeMigration < ActiveRecord::Migration[6.0]
end
# <—– missing down method
end
# up migration
def up
class SomeMigration < ActiveRecord::Migration[6.0]
# bad
@example
method.
either a ‘change` method or both an `up` and a `down`
Checks whether the migration implements
def on_class(node)
def on_class(node) return if !migration_class?(node) || change_method?(node) || up_and_down_methods?(node) add_offense(node) end