rubocop_canvas: fix add_reference non-transactional logic

we don't need to suggest `disable_ddl_transaction!` when adding
a non-indexed reference

fixes FOO-3298
test plan: specs

Change-Id: I33ca47954e5760bf3f14d8b240891713f735eeda
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/308301
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
Jeremy Stanley 2023-01-06 10:54:39 -07:00
parent 1e0ee0640e
commit 2502fd32ce
2 changed files with 5 additions and 5 deletions

View File

@ -104,13 +104,14 @@ module RuboCop
end
def check_add_reference(node)
check_non_transactional
arg = index_argument(node).first
if arg.nil? || (!false?(arg) && !algorithm_concurrently?(arg))
if arg.nil? || !false?(arg)
check_non_transactional
if arg.nil? || !algorithm_concurrently?(arg)
add_offense arg || node, message: INDEX_ALGORITHM_CONCURRENTLY_MSG, severity: :warning
end
end
end
def check_change_table(node)
ct_index(node).each { |subnode| check_add_index(subnode) }

View File

@ -145,7 +145,6 @@ describe RuboCop::Cop::Migration::AddIndex do
it "doesn't complain if not indexed" do
inspect_source(<<~RUBY)
class TestMigration < ActiveRecord::Migration
disable_ddl_transaction!
def up
add_reference :users, :organizations, index: false
end