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

20220715163254_update_notes_in_past.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1c46a3bc9dc9e41ae9045801cc273fef06e5987d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class UpdateNotesInPast < Gitlab::Database::Migration[2.0]
  restrict_gitlab_migration gitlab_schema: :gitlab_main

  def up
    loop do
      update_count = define_batchable_model('notes')
        .where('created_at < ?', '1970-01-01').limit(100)
        .update_all(created_at: '1970-01-01 00:00:00')

      break if update_count == 0
    end
  end

  def down
    # no op
  end
end