Skip to content
Snippets Groups Projects
Commit f94e176d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge branch '7-10-4' into '7-10-stable'

7.10.4

Adding quote_string to migration

See merge request !630

cc @job

See merge request !1817
parents 72b0cfe6 f876b7ca
No related branches found
No related tags found
No related merge requests found
class RemoveDuplicateTags < ActiveRecord::Migration
def up
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
duplicate_ids.delete origin_tag_id
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment