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/20230316073726_backfill_current_value_with_progress_work_item_progresses.rb')
-rw-r--r--db/post_migrate/20230316073726_backfill_current_value_with_progress_work_item_progresses.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/db/post_migrate/20230316073726_backfill_current_value_with_progress_work_item_progresses.rb b/db/post_migrate/20230316073726_backfill_current_value_with_progress_work_item_progresses.rb
new file mode 100644
index 00000000000..cad5c74bb8a
--- /dev/null
+++ b/db/post_migrate/20230316073726_backfill_current_value_with_progress_work_item_progresses.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class BackfillCurrentValueWithProgressWorkItemProgresses < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ each_batch('work_item_progresses', connection: connection) do |relation|
+ min, max = relation.pick('MIN(issue_id), MAX(issue_id)')
+
+ execute(<<~SQL)
+ UPDATE work_item_progresses SET current_value = progress
+ WHERE issue_id BETWEEN #{min} AND #{max}
+ SQL
+ end
+ end
+
+ def down
+ # no-op as the columns are newly added
+ end
+end