diff options
Diffstat (limited to 'db/post_migrate/20220715163254_update_notes_in_past.rb')
-rw-r--r-- | db/post_migrate/20220715163254_update_notes_in_past.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/db/post_migrate/20220715163254_update_notes_in_past.rb b/db/post_migrate/20220715163254_update_notes_in_past.rb new file mode 100644 index 00000000000..1c46a3bc9dc --- /dev/null +++ b/db/post_migrate/20220715163254_update_notes_in_past.rb @@ -0,0 +1,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 |