Skip to content
Snippets Groups Projects
Commit 34f1f97e authored by Krasimir Angelov's avatar Krasimir Angelov :two:
Browse files

Cleanup PK conversion for few notes related tables

Remove the following `integer` columns and the related triggers:

* todos.note_id
* system_note_metadata.note_id
* epic_user_mentions.note_id
* suggestions.note_id
* issue_user_mentions.note_id
* note_diff_files.diff_note_id
* snippet_user_mentions.note_id
* design_user_mentions.note_id
* vulnerability_user_mentions.note_id
* commit_user_mentions.note_id
* merge_request_user_mentions.note_id
* timelogs.note_id
* award_emoji.awardable_id

#414777

Changelog: removed
parent 53ab76fe
No related branches found
No related tags found
2 merge requests!123108Cleanup PK conversion for few notes related tables,!119439Draft: Prevent file variable content expansion in downstream pipeline
Showing
with 290 additions and 10 deletions
......@@ -3,7 +3,7 @@
class CommitUserMention < UserMention
include IgnorableColumns
ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
belongs_to :note
end
......@@ -3,7 +3,7 @@
class DesignUserMention < UserMention
include IgnorableColumns
ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
belongs_to :design, class_name: 'DesignManagement::Design'
belongs_to :note
......
......@@ -5,5 +5,5 @@ class IssueUserMention < UserMention
belongs_to :note
include IgnorableColumns
ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
end
......@@ -3,7 +3,7 @@
class MergeRequestUserMention < UserMention
include IgnorableColumns
ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
belongs_to :merge_request
belongs_to :note
......
......@@ -4,7 +4,7 @@ class NoteDiffFile < ApplicationRecord
include DiffFile
include IgnorableColumns
ignore_column :diff_note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
ignore_column :diff_note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
scope :referencing_sha, -> (oids, project_id:) do
joins(:diff_note).where(notes: { project_id: project_id, commit_id: oids })
......
......@@ -3,7 +3,7 @@
class SnippetUserMention < UserMention
include IgnorableColumns
ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
belongs_to :snippet
belongs_to :note
......
......@@ -5,7 +5,7 @@ class Suggestion < ApplicationRecord
include Suggestible
include IgnorableColumns
ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
belongs_to :note, inverse_of: :suggestions
validates :note, presence: true, unless: :importing?
......
......@@ -4,7 +4,7 @@ class SystemNoteMetadata < ApplicationRecord
include Importable
include IgnorableColumns
ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
# These notes's action text might contain a reference that is external.
# We should always force a deep validation upon references that are found
......
......@@ -5,7 +5,7 @@ class Timelog < ApplicationRecord
include IgnorableColumns
include Sortable
ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
before_save :set_project
......
......@@ -6,7 +6,7 @@ class Todo < ApplicationRecord
include EachBatch
include IgnorableColumns
ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
# Time to wait for todos being removed when not visible for user anymore.
# Prevents TODOs being removed by mistake, for example, removing access from a user
......
# frozen_string_literal: true
class CleanupBigintConversionForTodosForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
enable_lock_retries!
TABLE = :todos
COLUMNS = [:note_id]
def up
return unless should_run?
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
return unless should_run?
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
private
def should_run?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class CleanupBigintConversionForSystemNoteMetadataForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
enable_lock_retries!
TABLE = :system_note_metadata
COLUMNS = [:note_id]
def up
return unless should_run?
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
return unless should_run?
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
private
def should_run?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class CleanupBigintConversionForEpicUserMentionsForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
enable_lock_retries!
TABLE = :epic_user_mentions
COLUMNS = [:note_id]
def up
return unless should_run?
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
return unless should_run?
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
private
def should_run?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class CleanupBigintConversionForSuggestionsForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
enable_lock_retries!
TABLE = :suggestions
COLUMNS = [:note_id]
def up
return unless should_run?
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
return unless should_run?
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
private
def should_run?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class CleanupBigintConversionForIssueUserMentionsForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
enable_lock_retries!
TABLE = :issue_user_mentions
COLUMNS = [:note_id]
def up
return unless should_run?
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
return unless should_run?
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
private
def should_run?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class CleanupBigintConversionForNoteDiffFilesForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
enable_lock_retries!
TABLE = :note_diff_files
COLUMNS = [:diff_note_id]
def up
return unless should_run?
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
return unless should_run?
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
private
def should_run?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class CleanupBigintConversionForSnippetUserMentionsForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
enable_lock_retries!
TABLE = :snippet_user_mentions
COLUMNS = [:note_id]
def up
return unless should_run?
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
return unless should_run?
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
private
def should_run?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class CleanupBigintConversionForDesignUserMentionsForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
enable_lock_retries!
TABLE = :design_user_mentions
COLUMNS = [:note_id]
def up
return unless should_run?
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
return unless should_run?
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
private
def should_run?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class CleanupBigintConversionForVulnerabilityUserMentionsForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
enable_lock_retries!
TABLE = :vulnerability_user_mentions
COLUMNS = [:note_id]
def up
return unless should_run?
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
return unless should_run?
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
private
def should_run?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class CleanupBigintConversionForCommitUserMentionsForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
enable_lock_retries!
TABLE = :commit_user_mentions
COLUMNS = [:note_id]
def up
return unless should_run?
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
return unless should_run?
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
private
def should_run?
com_or_dev_or_test_but_not_jh?
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment