Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/background_migration/update_timelogs_null_spent_at.rb')
-rw-r--r--lib/gitlab/background_migration/update_timelogs_null_spent_at.rb39
1 files changed, 0 insertions, 39 deletions
diff --git a/lib/gitlab/background_migration/update_timelogs_null_spent_at.rb b/lib/gitlab/background_migration/update_timelogs_null_spent_at.rb
deleted file mode 100644
index b61f2ee7f4c..00000000000
--- a/lib/gitlab/background_migration/update_timelogs_null_spent_at.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module BackgroundMigration
- # Class to populate spent_at for timelogs
- class UpdateTimelogsNullSpentAt
- include Gitlab::Database::DynamicModelHelpers
-
- BATCH_SIZE = 100
-
- def perform(start_id, stop_id)
- define_batchable_model('timelogs', connection: connection)
- .where(spent_at: nil, id: start_id..stop_id)
- .each_batch(of: 100) do |subbatch|
- batch_start, batch_end = subbatch.pick('min(id), max(id)')
-
- update_timelogs(batch_start, batch_end)
- end
- end
-
- def update_timelogs(batch_start, batch_stop)
- execute(<<~SQL)
- UPDATE timelogs
- SET spent_at = created_at
- WHERE spent_at IS NULL
- AND timelogs.id BETWEEN #{batch_start} AND #{batch_stop};
- SQL
- end
-
- def connection
- @connection ||= ApplicationRecord.connection
- end
-
- def execute(sql)
- connection.execute(sql)
- end
- end
- end
-end