From af7db9579b69e098ce14336a0d1b8fe9b389c366 Mon Sep 17 00:00:00 2001 From: Tim McCarthy Date: Wed, 1 Oct 2025 13:16:49 +0200 Subject: [PATCH] Migration to fix broken namespaces on staging Created a migration to fix incorrect root_id's on namespaces in our staging environment Changelog: changed --- ...20251001104746_resync_namespace_root_id.rb | 30 +++++++++++++++++++ db/schema_migrations/20251001104746 | 1 + 2 files changed, 31 insertions(+) create mode 100644 db/post_migrate/20251001104746_resync_namespace_root_id.rb create mode 100644 db/schema_migrations/20251001104746 diff --git a/db/post_migrate/20251001104746_resync_namespace_root_id.rb b/db/post_migrate/20251001104746_resync_namespace_root_id.rb new file mode 100644 index 00000000000000..6752a252d7ebc9 --- /dev/null +++ b/db/post_migrate/20251001104746_resync_namespace_root_id.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class ResyncNamespaceRootId < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + milestone '18.5' + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + AFFECTED_NAMESPACE_IDS = [ + 2351878, 2351884, 2352260, 2352268, 2352273, 2352379, 2352383, 2352500, 2352504, 2352740, + 2352746, 2353770, 2353780, 2353876, 2353880, 2353885, 2354054, 2354062, 2354074, 2354214, + 2354221, 2354429, 2354644, 2354649, 2354658, 2354856, 2354958, 2354965, 2355661, 2355678, + 2355892, 2355899, 2355905, 2356086, 2356093, 2356099, 2356234, 2356434, 2356440, 2356446, + 2356790, 2356936, 2356946, 2356955, 2357299, 2357304, 2357309, 2357732, 2358120, 2358131, + 2358569, 2358575, 2477257, 2482324 + ] + + class Namespace < MigrationRecord + end + + def up + return unless Gitlab.com_except_jh? && Gitlab.staging? + + Namespace.where(id: AFFECTED_NAMESPACE_IDS).find_each do |root| + Namespace::TraversalHierarchy.sync_traversal_ids!(root) + end + end + + def down; end +end diff --git a/db/schema_migrations/20251001104746 b/db/schema_migrations/20251001104746 new file mode 100644 index 00000000000000..e3e06df529bb41 --- /dev/null +++ b/db/schema_migrations/20251001104746 @@ -0,0 +1 @@ +beb02bcb68d45fb24715a42e6b76de762f79f294d8593b2c7d15589acebe267e \ No newline at end of file -- GitLab