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

20231207194620_backfill_catalog_resources_visibility_level.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 808b0d983a81e9960aae3c36c71b63dbf57d9ca4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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