2021-02-16 15:09:50 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class BackfillUpdatedAtAfterRepositoryStorageMove < ActiveRecord::Migration[6.0]
|
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
|
|
|
BATCH_SIZE = 10_000
|
|
|
|
INTERVAL = 2.minutes
|
|
|
|
MIGRATION_CLASS = 'BackfillProjectUpdatedAtAfterRepositoryStorageMove'
|
|
|
|
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
2021-02-22 18:10:55 +00:00
|
|
|
class RepositoryStorageMove < ActiveRecord::Base
|
2021-02-16 15:09:50 +00:00
|
|
|
include EachBatch
|
|
|
|
|
|
|
|
self.table_name = 'project_repository_storage_moves'
|
|
|
|
end
|
|
|
|
|
|
|
|
def up
|
2021-02-22 18:10:55 +00:00
|
|
|
RepositoryStorageMove.reset_column_information
|
2021-02-16 15:09:50 +00:00
|
|
|
|
2021-02-22 18:10:55 +00:00
|
|
|
RepositoryStorageMove.select(:project_id).distinct.each_batch(of: BATCH_SIZE, column: :project_id) do |batch, index|
|
2021-02-16 15:09:50 +00:00
|
|
|
migrate_in(
|
|
|
|
INTERVAL * index,
|
|
|
|
MIGRATION_CLASS,
|
|
|
|
batch.pluck(:project_id)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
# No-op
|
|
|
|
end
|
|
|
|
end
|