Adding quote_string to migration
This commit is contained in:
parent
8a413174a5
commit
3bc717f010
1 changed files with 2 additions and 1 deletions
|
@ -1,7 +1,8 @@
|
||||||
class RemoveDuplicateTags < ActiveRecord::Migration
|
class RemoveDuplicateTags < ActiveRecord::Migration
|
||||||
def up
|
def up
|
||||||
select_all("SELECT name, COUNT(id) as cnt FROM tags GROUP BY name HAVING COUNT(id) > 1").each do |tag|
|
select_all("SELECT name, COUNT(id) as cnt FROM tags GROUP BY name HAVING COUNT(id) > 1").each do |tag|
|
||||||
duplicate_ids = select_all("SELECT id FROM tags WHERE name = '#{tag["name"]}'").map{|tag| tag["id"]}
|
tag_name = quote_string(tag["name"])
|
||||||
|
duplicate_ids = select_all("SELECT id FROM tags WHERE name = '#{tag_name}'").map{|tag| tag["id"]}
|
||||||
origin_tag_id = duplicate_ids.first
|
origin_tag_id = duplicate_ids.first
|
||||||
duplicate_ids.delete origin_tag_id
|
duplicate_ids.delete origin_tag_id
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue