Only indent if the subsequent line is a subquery
This commit is contained in:
parent
3f89d9c430
commit
ac089ba5af
1 changed files with 12 additions and 12 deletions
|
@ -8,18 +8,18 @@ class RenameDuplicatedVariableKey < ActiveRecord::Migration
|
|||
def up
|
||||
execute(<<~SQL)
|
||||
UPDATE ci_variables
|
||||
SET #{key} = CONCAT(#{key}, #{underscore}, id)
|
||||
WHERE id IN (
|
||||
SELECT *
|
||||
FROM ( -- MySQL requires an extra layer
|
||||
SELECT dup.id
|
||||
FROM ci_variables dup
|
||||
INNER JOIN (SELECT max(id) AS id, #{key}, project_id
|
||||
FROM ci_variables tmp
|
||||
GROUP BY #{key}, project_id) var
|
||||
USING (#{key}, project_id) where dup.id <> var.id
|
||||
) dummy
|
||||
)
|
||||
SET #{key} = CONCAT(#{key}, #{underscore}, id)
|
||||
WHERE id IN (
|
||||
SELECT *
|
||||
FROM ( -- MySQL requires an extra layer
|
||||
SELECT dup.id
|
||||
FROM ci_variables dup
|
||||
INNER JOIN (SELECT max(id) AS id, #{key}, project_id
|
||||
FROM ci_variables tmp
|
||||
GROUP BY #{key}, project_id) var
|
||||
USING (#{key}, project_id) where dup.id <> var.id
|
||||
) dummy
|
||||
)
|
||||
SQL
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue