Skip to content

Rails/ReversibleMigrationMethodDefinition false positive? #488

Closed
@coding-red-panda

Description

Expected behavior

I expect the Cop to not flag a correct migration as "wrong"

Actual behavior

The cop is currently flagging all migrations

Steps to reproduce the problem

# frozen_string_literal: true

# This migration removes the ActiveStorage Blob tables.
class RemoveActiveStorageBlobs < ::ActiveRecord::Migration[6.1]
  # Runs the migration in the correct direction
  def change
    drop_table :active_storage_blobs do |t|
      t.string :key, null: false
      t.string :filename, null: false
      t.string :content_type
      t.text :metadata
      t.bigint :byte_size, null: false
      t.string :checksum, null: false
      t.datetime :created_at, null: false
      t.index :key, unique: true
    end
  end
end

This is currently flagged:

db/migrate/20210513071056_remove_active_storage_blobs.rb:4:1: E: Rails/ReversibleMigrationMethodDefinition: Migrations must contain either a change method, or both an up and a down method.
class RemoveActiveStorageBlobs < ::ActiveRecord::Migration[6.1] ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:
You can see extension cop versions (e.g. rubocop-rails, rubocop-performance, and others) output by rubocop -V,
include them as well. Here's an example:

➜  customink_international git:(coding-bunny/bump_inkycop) ✗ bundle exec rubocop -V
1.14.0 (using Parser 3.0.1.1, rubocop-ast 1.5.0, running on ruby 3.0.0 x86_64-linux)
  - rubocop-performance 1.11.3
  - rubocop-rails 2.10.1
  - rubocop-rake 0.5.1
  - rubocop-rspec 2.3.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions