diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-06-27 21:14:38 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-06-27 21:14:38 +0800 |
commit | 42a9eea79186c02f1fdccec886d1202adb33fcf6 (patch) | |
tree | 43310daad106e0cf459b99c594a85b67dac0715e /db | |
parent | 7f3f053a7d2c720eb946c07a4b4bd09a54a72bbe (diff) | |
download | gitlab-ce-42a9eea79186c02f1fdccec886d1202adb33fcf6.tar.gz |
Better indent the SQLadd-ci_variables-environment_scope-mysql
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20170622135451_rename_duplicated_variable_key.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/db/migrate/20170622135451_rename_duplicated_variable_key.rb b/db/migrate/20170622135451_rename_duplicated_variable_key.rb index b88e7d7ba81..1005a212131 100644 --- a/db/migrate/20170622135451_rename_duplicated_variable_key.rb +++ b/db/migrate/20170622135451_rename_duplicated_variable_key.rb @@ -7,15 +7,18 @@ class RenameDuplicatedVariableKey < ActiveRecord::Migration def up execute(<<~SQL) - UPDATE ci_variables SET #{key} = CONCAT(#{key}, #{underscore}, id) + 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 + 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 + ) dummy ) SQL end |