Skip to content
Snippets Groups Projects
Commit 21ddde8d authored by Hordur Freyr Yngvason's avatar Hordur Freyr Yngvason 👶
Browse files

Backfill clusters_integration_elastic_stack.enabled

We are in the process of deprecating GitLab-managed apps feature in
GitLab, in favour of user-managed integrations. This migration backfills
the integration status based on the corresponding application status.

With this migration completed, we can start using the integration record
as the source of truth for whether to enable the integration.

Second part of #326560

Changelog: changed
parent f63d1d6a
No related branches found
No related tags found
1 merge request!61521Backfill clusters_integration_elastic_stack.enabled
---
title: Backfill clusters_integration_elastic_stack.enabled
merge_request: 61521
author:
type: changed
# frozen_string_literal: true
class BackfillClustersIntegrationElasticStackEnabled < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
ApplicationRecord.connection.execute(<<~SQL.squish)
WITH executed_at AS (VALUES (TIMEZONE('UTC', NOW())))
INSERT INTO clusters_integration_elasticstack(
cluster_id,
enabled,
chart_version,
created_at,
updated_at
)
SELECT
cluster_id,
true,
version,
(table executed_at),
(table executed_at)
FROM clusters_applications_elastic_stacks
WHERE status IN (3, 11)
ON CONFLICT(cluster_id) DO UPDATE SET
enabled = true,
updated_at = (table executed_at)
SQL
end
def down
# Irreversible
end
end
c30b4239e25a7c4f7018c9ab29a55ed56e8b03d9c59a1dfbff00c54d312f98b6
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment