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

20210518001450_backfill_clusters_integration_elastic_stack_enabled.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6d21945af000333bd412066acef2125a61f81e62 (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

class BackfillClustersIntegrationElasticStackEnabled < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  disable_ddl_transaction!

  def up
    ApplicationRecord.connection.execute(<<~SQL.squish)
      INSERT INTO clusters_integration_elasticstack(
        cluster_id,
        enabled,
        chart_version,
        created_at,
        updated_at
      )
        SELECT
          cluster_id,
          true,
          version,
          TIMEZONE('UTC', NOW()),
          TIMEZONE('UTC', NOW())
        FROM clusters_applications_elastic_stacks
        WHERE status IN (3, 11)
      ON CONFLICT(cluster_id) DO UPDATE SET
        enabled = true,
        updated_at = TIMEZONE('UTC', NOW())
    SQL
  end

  def down
    # Irreversible
  end
end