0
0
Fork 0

Fix Style/SlicingWithRange cop (#25923)

This commit is contained in:
Matt Jankowski 2023-07-12 04:03:06 -04:00 committed by GitHub
parent 658742b3cd
commit b8b2470cf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 13 additions and 28 deletions

View file

@ -6,7 +6,7 @@ class AddCaseInsensitiveIndexToTags < ActiveRecord::Migration[5.2]
def up
Tag.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM tags GROUP BY lower(name) HAVING count(*) > 1').to_ary.each do |row|
canonical_tag_id = row['ids'].split(',').first
redundant_tag_ids = row['ids'].split(',')[1..-1]
redundant_tag_ids = row['ids'].split(',')[1..]
safety_assured do
execute "UPDATE accounts_tags AS t0 SET tag_id = #{canonical_tag_id} WHERE tag_id IN (#{redundant_tag_ids.join(', ')}) AND NOT EXISTS (SELECT t1.tag_id FROM accounts_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.account_id = t0.account_id)"