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/20231207194620_backfill_catalog_resources_visibility_level.rb')
-rw-r--r--db/post_migrate/20231207194620_backfill_catalog_resources_visibility_level.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/db/post_migrate/20231207194620_backfill_catalog_resources_visibility_level.rb b/db/post_migrate/20231207194620_backfill_catalog_resources_visibility_level.rb
new file mode 100644
index 00000000000..808b0d983a8
--- /dev/null
+++ b/db/post_migrate/20231207194620_backfill_catalog_resources_visibility_level.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class BackfillCatalogResourcesVisibilityLevel < Gitlab::Database::Migration[2.2]
+ milestone '16.7'
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ sql = <<-SQL
+ UPDATE catalog_resources
+ SET visibility_level = projects.visibility_level
+ FROM projects
+ WHERE catalog_resources.project_id = projects.id
+ SQL
+
+ execute(sql)
+ end
+
+ def down
+ # no-op
+
+ # The `visibility_level` column in `catalog_resources` is denormalized;
+ # it should always stay in sync with the corresponding data in `projects`.
+ end
+end