Skip to content
Snippets Groups Projects
Commit 89bb700c authored by Adam Hegyi's avatar Adam Hegyi :coffee: Committed by Mayra Cabrera
Browse files

Migrate remaining users with null private_profile

parent b3ca39aa
No related branches found
No related tags found
No related merge requests found
---
title: Migrate remaining users with null private_profile
merge_request: 31708
author:
type: other
# frozen_string_literal: true
class MigratePrivateProfileNulls < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
DELAY = 5.minutes.to_i
BATCH_SIZE = 1_000
disable_ddl_transaction!
class User < ActiveRecord::Base
self.table_name = 'users'
include ::EachBatch
end
def up
# Migration will take about 7 hours
User.where(private_profile: nil).each_batch(of: BATCH_SIZE) do |batch, index|
range = batch.pluck(Arel.sql("MIN(id)"), Arel.sql("MAX(id)")).first
delay = index * DELAY
BackgroundMigrationWorker.perform_in(delay.seconds, 'MigrateNullPrivateProfileToFalse', [*range])
end
end
def down
# noop
end
end
Loading
Loading
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
 
ActiveRecord::Schema.define(version: 2019_08_06_071559) do
ActiveRecord::Schema.define(version: 2019_08_12_070645) do
 
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment