diff options
Diffstat (limited to 'db/post_migrate/20210119122354_alter_vsa_issue_first_mentioned_in_commit_value.rb')
-rw-r--r-- | db/post_migrate/20210119122354_alter_vsa_issue_first_mentioned_in_commit_value.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/db/post_migrate/20210119122354_alter_vsa_issue_first_mentioned_in_commit_value.rb b/db/post_migrate/20210119122354_alter_vsa_issue_first_mentioned_in_commit_value.rb new file mode 100644 index 00000000000..132d72e180b --- /dev/null +++ b/db/post_migrate/20210119122354_alter_vsa_issue_first_mentioned_in_commit_value.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +class AlterVsaIssueFirstMentionedInCommitValue < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + ISSUE_FIRST_MENTIONED_IN_COMMIT_FOSS = 2 + ISSUE_FIRST_MENTIONED_IN_COMMIT_EE = 6 + + class GroupStage < ActiveRecord::Base + self.table_name = 'analytics_cycle_analytics_group_stages' + + include EachBatch + end + + def up + GroupStage.each_batch(of: 100) do |relation| + relation + .where(start_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_EE) + .update_all(start_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_FOSS) + + relation + .where(end_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_EE) + .update_all(end_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_FOSS) + end + end + + def down + # rollback is not needed, the identifier "6" is the same as identifier "2" on the application level + end +end |