Commit ac089ba5 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Only indent if the subsequent line is a subquery

parent 3f89d9c4
...@@ -8,18 +8,18 @@ class RenameDuplicatedVariableKey < ActiveRecord::Migration ...@@ -8,18 +8,18 @@ class RenameDuplicatedVariableKey < ActiveRecord::Migration
def up def up
execute(<<~SQL) execute(<<~SQL)
UPDATE ci_variables UPDATE ci_variables
SET #{key} = CONCAT(#{key}, #{underscore}, id) SET #{key} = CONCAT(#{key}, #{underscore}, id)
WHERE id IN ( WHERE id IN (
SELECT * SELECT *
FROM ( -- MySQL requires an extra layer FROM ( -- MySQL requires an extra layer
SELECT dup.id SELECT dup.id
FROM ci_variables dup FROM ci_variables dup
INNER JOIN (SELECT max(id) AS id, #{key}, project_id INNER JOIN (SELECT max(id) AS id, #{key}, project_id
FROM ci_variables tmp FROM ci_variables tmp
GROUP BY #{key}, project_id) var GROUP BY #{key}, project_id) var
USING (#{key}, project_id) where dup.id <> var.id USING (#{key}, project_id) where dup.id <> var.id
) dummy ) dummy
) )
SQL SQL
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment