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

20231019223224_backfill_catalog_resources_name_and_description.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fd5db7621e3b7089abaa50b6868425806bd2dcbf (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
# frozen_string_literal: true

class BackfillCatalogResourcesNameAndDescription < Gitlab::Database::Migration[2.1]
  restrict_gitlab_migration gitlab_schema: :gitlab_main

  def up
    sql = <<-SQL
      UPDATE catalog_resources
      SET name = projects.name,
          description = projects.description
      FROM projects
      WHERE catalog_resources.project_id = projects.id
    SQL

    execute(sql)
  end

  def down
    # no-op

    # The `name` and `description` columns in `catalog_resources` are denormalized;
    # they should always stay in sync with the corresponding data in `projects`.
  end
end