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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20220204110725_backfill_cycle_analytics_aggregations.rb')
-rw-r--r--db/post_migrate/20220204110725_backfill_cycle_analytics_aggregations.rb33
1 files changed, 0 insertions, 33 deletions
diff --git a/db/post_migrate/20220204110725_backfill_cycle_analytics_aggregations.rb b/db/post_migrate/20220204110725_backfill_cycle_analytics_aggregations.rb
deleted file mode 100644
index 933ad747c5c..00000000000
--- a/db/post_migrate/20220204110725_backfill_cycle_analytics_aggregations.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-class BackfillCycleAnalyticsAggregations < Gitlab::Database::Migration[1.0]
- BATCH_SIZE = 50
-
- def up
- model = define_batchable_model('analytics_cycle_analytics_group_value_streams')
-
- model.each_batch(of: BATCH_SIZE) do |relation|
- execute <<~SQL
- WITH records_to_be_inserted AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported} (
- SELECT root_ancestor.id AS group_id
- FROM (#{relation.select(:group_id).to_sql}) as value_streams,
- LATERAL (
- WITH RECURSIVE "base_and_ancestors" AS (
- (SELECT "namespaces"."id", "namespaces"."parent_id" FROM "namespaces" WHERE "namespaces"."id" = value_streams.group_id)
- UNION
- (SELECT "namespaces"."id", "namespaces"."parent_id" FROM "namespaces", "base_and_ancestors" WHERE "namespaces"."id" = "base_and_ancestors"."parent_id")
- )
- SELECT "namespaces"."id" FROM "base_and_ancestors" as "namespaces" WHERE parent_id IS NULL LIMIT 1
- ) as root_ancestor
- )
- INSERT INTO "analytics_cycle_analytics_aggregations"
- SELECT * FROM "records_to_be_inserted"
- ON CONFLICT DO NOTHING
- SQL
- end
- end
-
- def down
- # no-op
- end
-end