diff options
Diffstat (limited to 'db/post_migrate/20210518001450_backfill_clusters_integration_elastic_stack_enabled.rb')
-rw-r--r-- | db/post_migrate/20210518001450_backfill_clusters_integration_elastic_stack_enabled.rb | 34 |
1 files changed, 34 insertions, 0 deletions
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 00000000000..6d21945af00 --- /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 |