diff options
Diffstat (limited to 'db/post_migrate/20200305082754_remove_duplicate_labels_from_project.rb')
-rw-r--r-- | db/post_migrate/20200305082754_remove_duplicate_labels_from_project.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/db/post_migrate/20200305082754_remove_duplicate_labels_from_project.rb b/db/post_migrate/20200305082754_remove_duplicate_labels_from_project.rb index 33f8118534d..4bb43da43bb 100644 --- a/db/post_migrate/20200305082754_remove_duplicate_labels_from_project.rb +++ b/db/post_migrate/20200305082754_remove_duplicate_labels_from_project.rb @@ -55,7 +55,7 @@ class RemoveDuplicateLabelsFromProject < ActiveRecord::Migration[6.0] # project_id title template description type color duplicate_labels = ApplicationRecord.connection.execute(<<-SQL.squish) -WITH data AS ( +WITH data AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported} ( SELECT labels.*, row_number() OVER (PARTITION BY labels.project_id, labels.title, labels.template, labels.description, labels.type, labels.color ORDER BY labels.id) AS row_number, #{CREATE} AS restore_action @@ -83,7 +83,7 @@ WITH data AS ( # then add `_duplicate#{ID}` soft_duplicates = ApplicationRecord.connection.execute(<<-SQL.squish) -WITH data AS ( +WITH data AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported} ( SELECT *, substring(title from 1 for 245 - length(id::text)) || '_duplicate' || id::text as new_title, @@ -108,7 +108,7 @@ WHERE labels.id IN (#{soft_duplicates.map { |dup| dup["id"] }.join(", ")}); def restore_renamed_labels(start_id, stop_id) # the backup label IDs are not incremental, they are copied directly from the Labels table ApplicationRecord.connection.execute(<<-SQL.squish) -WITH backups AS ( +WITH backups AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported} ( SELECT id, title FROM backup_labels WHERE project_id BETWEEN #{start_id} AND #{stop_id} AND |