summaryrefslogtreecommitdiff
path: root/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-02-22 16:50:15 -0600
committerDouwe Maan <douwe@selenight.nl>2017-02-23 09:33:05 -0600
commit1fe7501b49f896b74102c4b970310aa9ae34da85 (patch)
treece271afb0fbaaa14291c1dc9009cd7815ee25463 /db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
parentbdbc7d967a0c3d95d5e4ea19a2a5be41268d3540 (diff)
downloadgitlab-ce-1fe7501b49f896b74102c4b970310aa9ae34da85.tar.gz
Revert "Prefer leading style for Style/DotPosition"
This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
Diffstat (limited to 'db/migrate/20161207231620_fixup_environment_name_uniqueness.rb')
-rw-r--r--db/migrate/20161207231620_fixup_environment_name_uniqueness.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
index f73e4f6c99b..a20a903a752 100644
--- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
+++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
@@ -8,11 +8,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration
environments = Arel::Table.new(:environments)
# Get all [project_id, name] pairs that occur more than once
- finder_sql = environments
- .group(environments[:project_id], environments[:name])
- .having(Arel.sql("COUNT(1)").gt(1))
- .project(environments[:project_id], environments[:name])
- .to_sql
+ finder_sql = environments.
+ group(environments[:project_id], environments[:name]).
+ having(Arel.sql("COUNT(1)").gt(1)).
+ project(environments[:project_id], environments[:name]).
+ to_sql
conflicting = connection.exec_query(finder_sql)
@@ -28,12 +28,12 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration
# Rename conflicting environments by appending "-#{id}" to all but the first
def fix_duplicates(project_id, name)
environments = Arel::Table.new(:environments)
- finder_sql = environments
- .where(environments[:project_id].eq(project_id))
- .where(environments[:name].eq(name))
- .order(environments[:id].asc)
- .project(environments[:id], environments[:name])
- .to_sql
+ finder_sql = environments.
+ where(environments[:project_id].eq(project_id)).
+ where(environments[:name].eq(name)).
+ order(environments[:id].asc).
+ project(environments[:id], environments[:name]).
+ to_sql
# Now we have the data for all the conflicting rows
conflicts = connection.exec_query(finder_sql).rows
@@ -41,11 +41,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration
conflicts.each do |id, name|
update_sql =
- Arel::UpdateManager.new(ActiveRecord::Base)
- .table(environments)
- .set(environments[:name] => name + "-" + id.to_s)
- .where(environments[:id].eq(id))
- .to_sql
+ Arel::UpdateManager.new(ActiveRecord::Base).
+ table(environments).
+ set(environments[:name] => name + "-" + id.to_s).
+ where(environments[:id].eq(id)).
+ to_sql
connection.exec_update(update_sql, self.class.name, [])
end