Commit 75ed8a09 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch...

Merge branch 'blackst0ne-rails5-wrong-number-of-arguments-given-1-expected-0-in-20170324160416_migrate_user_activities_to_users_last_activity_on-rb' into 'master'

Resolve "[Rails5] wrong number of arguments (given 1, expected 0) in 20170324160416_migrate_user_activities_to_users_last_activity_on.rb"

Closes #47374

See merge request gitlab-org/gitlab-ce!19475
parents 35bf473f 1da00653
class FixupEnvironmentNameUniqueness < ActiveRecord::Migration class FixupEnvironmentNameUniqueness < ActiveRecord::Migration
include Gitlab::Database::ArelMethods
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = true DOWNTIME = true
...@@ -41,7 +42,7 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration ...@@ -41,7 +42,7 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration
conflicts.each do |id, name| conflicts.each do |id, name|
update_sql = update_sql =
Arel::UpdateManager.new(ActiveRecord::Base) arel_update_manager
.table(environments) .table(environments)
.set(environments[:name] => name + "-" + id.to_s) .set(environments[:name] => name + "-" + id.to_s)
.where(environments[:id].eq(id)) .where(environments[:id].eq(id))
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
class AddEnvironmentSlug < ActiveRecord::Migration class AddEnvironmentSlug < ActiveRecord::Migration
include Gitlab::Database::ArelMethods
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = true DOWNTIME = true
...@@ -19,7 +20,7 @@ class AddEnvironmentSlug < ActiveRecord::Migration ...@@ -19,7 +20,7 @@ class AddEnvironmentSlug < ActiveRecord::Migration
finder = environments.project(:id, :name) finder = environments.project(:id, :name)
connection.exec_query(finder.to_sql).rows.each do |id, name| connection.exec_query(finder.to_sql).rows.each do |id, name|
updater = Arel::UpdateManager.new(ActiveRecord::Base) updater = arel_update_manager
.table(environments) .table(environments)
.set(environments[:slug] => generate_slug(name)) .set(environments[:slug] => generate_slug(name))
.where(environments[:id].eq(id)) .where(environments[:id].eq(id))
......
class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration
include Gitlab::Database::ArelMethods
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
BATCH_SIZE = 500 BATCH_SIZE = 500
...@@ -33,7 +34,7 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration ...@@ -33,7 +34,7 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration
end end
updates.each do |visibility_level, project_ids| updates.each do |visibility_level, project_ids|
updater = Arel::UpdateManager.new(ActiveRecord::Base) updater = arel_update_manager
.table(projects) .table(projects)
.set(projects[:visibility_level] => visibility_level) .set(projects[:visibility_level] => visibility_level)
.where(projects[:id].in(project_ids)) .where(projects[:id].in(project_ids))
......
# rubocop:disable Migration/UpdateLargeTable # rubocop:disable Migration/UpdateLargeTable
class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration
include Gitlab::Database::ArelMethods
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
...@@ -39,7 +40,7 @@ class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration ...@@ -39,7 +40,7 @@ class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration
activities = activities(day.at_beginning_of_day, day.at_end_of_day, page: page) activities = activities(day.at_beginning_of_day, day.at_end_of_day, page: page)
update_sql = update_sql =
Arel::UpdateManager.new(ActiveRecord::Base) arel_update_manager
.table(users_table) .table(users_table)
.set(users_table[:last_activity_on] => day.to_date) .set(users_table[:last_activity_on] => day.to_date)
.where(users_table[:username].in(activities.map(&:first))) .where(users_table[:username].in(activities.map(&:first)))
......
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