diff --git a/changelogs/unreleased/backfill-clusters-integration-elatic-stack-enabled.yml b/changelogs/unreleased/backfill-clusters-integration-elatic-stack-enabled.yml new file mode 100644 index 0000000000000000000000000000000000000000..a37a470cb67ab1387c900f7bc99c17003d33192a --- /dev/null +++ b/changelogs/unreleased/backfill-clusters-integration-elatic-stack-enabled.yml @@ -0,0 +1,5 @@ +--- +title: Backfill clusters_integration_elastic_stack.enabled +merge_request: 61521 +author: +type: changed diff --git a/db/post_migrate/20210518001450_backfill_clusters_integration_elastic_stack_enabled.rb b/db/post_migrate/20210518001450_backfill_clusters_integration_elastic_stack_enabled.rb new file mode 100644 index 0000000000000000000000000000000000000000..6d21945af000333bd412066acef2125a61f81e62 --- /dev/null +++ b/db/post_migrate/20210518001450_backfill_clusters_integration_elastic_stack_enabled.rb @@ -0,0 +1,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 diff --git a/db/schema_migrations/20210518001450 b/db/schema_migrations/20210518001450 new file mode 100644 index 0000000000000000000000000000000000000000..5f3694d8b9351ef33c2ffd07d2387d419af72448 --- /dev/null +++ b/db/schema_migrations/20210518001450 @@ -0,0 +1 @@ +212a2db8b1183eb4ae313eacae7d54f2bec26c5ea3f961981d34e57ca1420ad9 \ No newline at end of file