summaryrefslogtreecommitdiff
path: root/db/post_migrate/20190524073827_schedule_fill_valid_time_for_pages_domain_certificates.rb
blob: 1d8510e45145000c6bbe4e252931b462d81bf21a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class ScheduleFillValidTimeForPagesDomainCertificates < ActiveRecord::Migration[5.1]
  include Gitlab::Database::MigrationHelpers

  MIGRATION = 'FillValidTimeForPagesDomainCertificate'
  BATCH_SIZE = 500
  BATCH_TIME = 5.minutes

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  disable_ddl_transaction!

  class PagesDomain < ActiveRecord::Base
    include ::EachBatch

    self.table_name = 'pages_domains'
  end

  def up
    queue_background_migration_jobs_by_range_at_intervals(
      PagesDomain.where.not(certificate: [nil, '']),
      MIGRATION,
      BATCH_TIME,
      batch_size: BATCH_SIZE)
  end

  def down
  end
end