From 01bc3af4142297e4af5e7dd5a4792a6bbbf0f116 Mon Sep 17 00:00:00 2001 From: carlad-gl Date: Fri, 10 May 2024 14:33:50 +0200 Subject: [PATCH 1/5] Ignore imported column in relevant models Prior to removing the unused imported column, we need the active record models to first ignore the column. Changelog: fixed --- app/models/design_management/design.rb | 2 ++ app/models/epic.rb | 2 ++ app/models/event.rb | 2 ++ app/models/issue.rb | 1 + app/models/merge_request.rb | 1 + app/models/note.rb | 2 ++ app/models/resource_label_event.rb | 2 ++ app/models/resource_milestone_event.rb | 2 ++ app/models/resource_state_event.rb | 2 ++ app/models/snippet.rb | 2 ++ 10 files changed, 18 insertions(+) diff --git a/app/models/design_management/design.rb b/app/models/design_management/design.rb index c5c0ca04510e4a..a4c67f789b3031 100644 --- a/app/models/design_management/design.rb +++ b/app/models/design_management/design.rb @@ -17,6 +17,8 @@ class Design < ApplicationRecord include CacheMarkdownField include Subscribable + ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' + cache_markdown_field :description belongs_to :project, inverse_of: :designs diff --git a/app/models/epic.rb b/app/models/epic.rb index 81cd342576fd42..42c57f2906e821 100644 --- a/app/models/epic.rb +++ b/app/models/epic.rb @@ -5,6 +5,8 @@ class Epic < ApplicationRecord include IgnorableColumns + ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' + def self.link_reference_pattern nil end diff --git a/app/models/event.rb b/app/models/event.rb index c046cd81419dc6..f5a3c72cc5749d 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -12,6 +12,8 @@ class Event < ApplicationRecord include EachBatch include Import::HasImportSource + ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' + ACTIONS = HashWithIndifferentAccess.new( created: 1, updated: 2, diff --git a/app/models/issue.rb b/app/models/issue.rb index 6cc5cb8ca60eee..aff368a6fad80a 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -58,6 +58,7 @@ class Issue < ApplicationRecord # prevent caching this column by rails, as we want to easily remove it after the backfilling ignore_column :tmp_epic_id, remove_with: '16.11', remove_after: '2024-03-31' + ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' belongs_to :project belongs_to :namespace, inverse_of: :issues diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 6163b378916f59..22431acbb3a24b 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -25,6 +25,7 @@ class MergeRequest < ApplicationRecord include Todoable include Spammable + ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' ignore_columns :head_pipeline_id_convert_to_bigint, remove_with: '17.1', remove_after: '2024-06-14' extend ::Gitlab::Utils::Override diff --git a/app/models/note.rb b/app/models/note.rb index 010b0b790a7a46..78a7914607ba72 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -26,6 +26,8 @@ class Note < ApplicationRecord include EachBatch include Spammable + ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' + cache_markdown_field :note, pipeline: :note, issuable_reference_expansion_enabled: true redact_field :note diff --git a/app/models/resource_label_event.rb b/app/models/resource_label_event.rb index bd3057f37dc4c3..4ffd2c6553708a 100644 --- a/app/models/resource_label_event.rb +++ b/app/models/resource_label_event.rb @@ -5,6 +5,8 @@ class ResourceLabelEvent < ResourceEvent include MergeRequestResourceEvent include Import::HasImportSource + ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' + cache_markdown_field :reference belongs_to :label diff --git a/app/models/resource_milestone_event.rb b/app/models/resource_milestone_event.rb index ba16a986ce267a..5a5267db92f7e0 100644 --- a/app/models/resource_milestone_event.rb +++ b/app/models/resource_milestone_event.rb @@ -4,6 +4,8 @@ class ResourceMilestoneEvent < ResourceTimeboxEvent include EachBatch include Import::HasImportSource + ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' + belongs_to :milestone scope :include_relations, -> { includes(:user, milestone: [:project, :group]) } diff --git a/app/models/resource_state_event.rb b/app/models/resource_state_event.rb index 5be6eeef68ac31..a2d3ced99a71db 100644 --- a/app/models/resource_state_event.rb +++ b/app/models/resource_state_event.rb @@ -5,6 +5,8 @@ class ResourceStateEvent < ResourceEvent include Importable include Import::HasImportSource + ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' + validate :exactly_one_issuable, unless: :importing? belongs_to :source_merge_request, class_name: 'MergeRequest', foreign_key: :source_merge_request_id diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 444c75ca4b7afd..35846082cea8cf 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -22,6 +22,8 @@ class Snippet < ApplicationRecord include EachBatch include Import::HasImportSource + ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' + MAX_FILE_COUNT = 10 DESCRIPTION_LENGTH_MAX = 1.megabyte -- GitLab From a82ad75344e0e2a3161bf0b07a691421957dbb76 Mon Sep 17 00:00:00 2001 From: carlad-gl Date: Fri, 10 May 2024 16:36:59 +0200 Subject: [PATCH 2/5] Add IgnorableColumns class --- app/models/design_management/design.rb | 1 + app/models/event.rb | 1 + app/models/note.rb | 1 + app/models/resource_label_event.rb | 1 + app/models/resource_milestone_event.rb | 1 + app/models/resource_state_event.rb | 1 + app/models/snippet.rb | 2 +- 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/design_management/design.rb b/app/models/design_management/design.rb index a4c67f789b3031..5b72e8036c7fb8 100644 --- a/app/models/design_management/design.rb +++ b/app/models/design_management/design.rb @@ -16,6 +16,7 @@ class Design < ApplicationRecord include Participable include CacheMarkdownField include Subscribable + include IgnorableColumns ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' diff --git a/app/models/event.rb b/app/models/event.rb index f5a3c72cc5749d..f56cbe7409dac2 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -11,6 +11,7 @@ class Event < ApplicationRecord include ShaAttribute include EachBatch include Import::HasImportSource + include IgnorableColumns ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' diff --git a/app/models/note.rb b/app/models/note.rb index 78a7914607ba72..a846e4b1769212 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -25,6 +25,7 @@ class Note < ApplicationRecord include Sortable include EachBatch include Spammable + include IgnorableColumns ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' diff --git a/app/models/resource_label_event.rb b/app/models/resource_label_event.rb index 4ffd2c6553708a..1ac2320b209e56 100644 --- a/app/models/resource_label_event.rb +++ b/app/models/resource_label_event.rb @@ -4,6 +4,7 @@ class ResourceLabelEvent < ResourceEvent include CacheMarkdownField include MergeRequestResourceEvent include Import::HasImportSource + include IgnorableColumns ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' diff --git a/app/models/resource_milestone_event.rb b/app/models/resource_milestone_event.rb index 5a5267db92f7e0..4a320ae6047372 100644 --- a/app/models/resource_milestone_event.rb +++ b/app/models/resource_milestone_event.rb @@ -3,6 +3,7 @@ class ResourceMilestoneEvent < ResourceTimeboxEvent include EachBatch include Import::HasImportSource + include IgnorableColumns ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' diff --git a/app/models/resource_state_event.rb b/app/models/resource_state_event.rb index a2d3ced99a71db..a35697b5d3b2c7 100644 --- a/app/models/resource_state_event.rb +++ b/app/models/resource_state_event.rb @@ -4,6 +4,7 @@ class ResourceStateEvent < ResourceEvent include MergeRequestResourceEvent include Importable include Import::HasImportSource + include IgnorableColumns ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 35846082cea8cf..73904dc77d8766 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -13,7 +13,6 @@ class Snippet < ApplicationRecord include Editable include Gitlab::SQL::Pattern include FromUnion - include IgnorableColumns include HasRepository include CanMoveRepositoryStorage include AfterCommitQueue @@ -21,6 +20,7 @@ class Snippet < ApplicationRecord include CreatedAtFilterable include EachBatch include Import::HasImportSource + include IgnorableColumns ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' -- GitLab From 67036fc7ad6a0fd38cfbead302094abbd4825a92 Mon Sep 17 00:00:00 2001 From: carlad-gl Date: Thu, 16 May 2024 15:52:27 +0200 Subject: [PATCH 3/5] Remove ignore from epic model --- app/models/epic.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/epic.rb b/app/models/epic.rb index 42c57f2906e821..81cd342576fd42 100644 --- a/app/models/epic.rb +++ b/app/models/epic.rb @@ -5,8 +5,6 @@ class Epic < ApplicationRecord include IgnorableColumns - ignore_column :imported, remove_with: '17.2', remove_after: '2024-07-22' - def self.link_reference_pattern nil end -- GitLab From 4cff91b1e260fbccda6dcbafe5c2c5449b70f8a9 Mon Sep 17 00:00:00 2001 From: carlad-gl Date: Fri, 17 May 2024 12:18:56 +0200 Subject: [PATCH 4/5] Update design model attributes --- .../copy_design_collection_model_attributes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitlab/design_management/copy_design_collection_model_attributes.yml b/lib/gitlab/design_management/copy_design_collection_model_attributes.yml index 2d2ad14bda539f..d1d191313c882b 100644 --- a/lib/gitlab/design_management/copy_design_collection_model_attributes.yml +++ b/lib/gitlab/design_management/copy_design_collection_model_attributes.yml @@ -17,7 +17,7 @@ design_attributes: - filename - relative_position - description - - imported + - imported_from version_attributes: - author_id -- GitLab From 44d7578fc2eab07c834b5c8c9d8b56537798ece2 Mon Sep 17 00:00:00 2001 From: carlad-gl Date: Tue, 21 May 2024 14:34:30 +0200 Subject: [PATCH 5/5] Fix failing specs --- .../copy_design_collection_model_attributes.yml | 1 - .../legacy_github_import/pull_request_formatter.rb | 3 +-- .../legacy_github_import/pull_request_formatter_spec.rb | 9 +++------ 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/gitlab/design_management/copy_design_collection_model_attributes.yml b/lib/gitlab/design_management/copy_design_collection_model_attributes.yml index d1d191313c882b..6b17a7d8fd6bac 100644 --- a/lib/gitlab/design_management/copy_design_collection_model_attributes.yml +++ b/lib/gitlab/design_management/copy_design_collection_model_attributes.yml @@ -17,7 +17,6 @@ design_attributes: - filename - relative_position - description - - imported_from version_attributes: - author_id diff --git a/lib/gitlab/legacy_github_import/pull_request_formatter.rb b/lib/gitlab/legacy_github_import/pull_request_formatter.rb index 72adba30093da4..10ace7a09f8cca 100644 --- a/lib/gitlab/legacy_github_import/pull_request_formatter.rb +++ b/lib/gitlab/legacy_github_import/pull_request_formatter.rb @@ -22,8 +22,7 @@ def attributes author_id: author_id, assignee_id: assignee_id, created_at: raw_data[:created_at], - updated_at: raw_data[:updated_at], - imported: true + updated_at: raw_data[:updated_at] } end diff --git a/spec/lib/gitlab/legacy_github_import/pull_request_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/pull_request_formatter_spec.rb index 1555e3e0d4c87a..a437a6b1b57188 100644 --- a/spec/lib/gitlab/legacy_github_import/pull_request_formatter_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/pull_request_formatter_spec.rb @@ -66,8 +66,7 @@ author_id: project.creator_id, assignee_id: nil, created_at: created_at, - updated_at: updated_at, - imported: true + updated_at: updated_at } expect(pull_request.attributes).to eq(expected) @@ -93,8 +92,7 @@ author_id: project.creator_id, assignee_id: nil, created_at: created_at, - updated_at: updated_at, - imported: true + updated_at: updated_at } expect(pull_request.attributes).to eq(expected) @@ -121,8 +119,7 @@ author_id: project.creator_id, assignee_id: nil, created_at: created_at, - updated_at: updated_at, - imported: true + updated_at: updated_at } expect(pull_request.attributes).to eq(expected) -- GitLab