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 'db/post_migrate/20220426185933_backfill_deployments_finished_at.rb')
-rw-r--r--db/post_migrate/20220426185933_backfill_deployments_finished_at.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/db/post_migrate/20220426185933_backfill_deployments_finished_at.rb b/db/post_migrate/20220426185933_backfill_deployments_finished_at.rb
new file mode 100644
index 00000000000..860756de298
--- /dev/null
+++ b/db/post_migrate/20220426185933_backfill_deployments_finished_at.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class BackfillDeploymentsFinishedAt < Gitlab::Database::Migration[2.0]
+ DEPLOYMENT_STATUS_SUCCESS = 2 # Equivalent to Deployment.statuses[:success]
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ BATCH_SIZE = 100
+
+ def up
+ define_batchable_model('deployments')
+ .where(finished_at: nil)
+ .where(status: DEPLOYMENT_STATUS_SUCCESS)
+ .each_batch(of: BATCH_SIZE) { |relation| relation.update_all('finished_at = created_at') }
+ end
+
+ def down
+ # no-op
+ end
+end