Commit 6ddfba24 authored by Krasimir Angelov's avatar Krasimir Angelov

Merge branch...

Merge branch '338055-address-the-primary-key-overflow-risk-for-the-taggings-table-step-3-drop-temporary-columns' into 'master'

Resolve "Address the Primary Key Overflow risk for the taggings table - Step 3: remove temporary columns and trigger"

See merge request gitlab-org/gitlab!69639
parents c0367c7f f9b8e8d7
...@@ -11,8 +11,8 @@ raise "Counter cache is not disabled" if ...@@ -11,8 +11,8 @@ raise "Counter cache is not disabled" if
ActsAsTaggableOn::Tagging.reflections["tag"].options[:counter_cache] ActsAsTaggableOn::Tagging.reflections["tag"].options[:counter_cache]
ActsAsTaggableOn::Tagging.include IgnorableColumns ActsAsTaggableOn::Tagging.include IgnorableColumns
ActsAsTaggableOn::Tagging.ignore_column :id_convert_to_bigint, remove_with: '14.2', remove_after: '2021-08-22' ActsAsTaggableOn::Tagging.ignore_column :id_convert_to_bigint, remove_with: '14.5', remove_after: '2021-10-22'
ActsAsTaggableOn::Tagging.ignore_column :taggable_id_convert_to_bigint, remove_with: '14.2', remove_after: '2021-08-22' ActsAsTaggableOn::Tagging.ignore_column :taggable_id_convert_to_bigint, remove_with: '14.5', remove_after: '2021-10-22'
# The tags and taggings are supposed to be part of `gitlab_ci` # The tags and taggings are supposed to be part of `gitlab_ci`
ActsAsTaggableOn::Tag.gitlab_schema = :gitlab_ci ActsAsTaggableOn::Tag.gitlab_schema = :gitlab_ci
......
# frozen_string_literal: true
class DropTemporaryColumnsAndTriggersForTaggings < Gitlab::Database::Migration[1.0]
enable_lock_retries!
TABLE = 'taggings'
COLUMNS = %w(id taggable_id)
# rubocop:disable Migration/WithLockRetriesDisallowedMethod
def up
cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
# rubocop:enable Migration/WithLockRetriesDisallowedMethod
def down
restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
end
c707c0879e439de95f24f8fe2084388276a46c5e0ee30e4134a43e22ca19b4ec
\ No newline at end of file
...@@ -86,16 +86,6 @@ BEGIN ...@@ -86,16 +86,6 @@ BEGIN
END; END;
$$; $$;
CREATE FUNCTION trigger_aebe8b822ad3() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW."id_convert_to_bigint" := NEW."id";
NEW."taggable_id_convert_to_bigint" := NEW."taggable_id";
RETURN NEW;
END;
$$;
CREATE TABLE audit_events ( CREATE TABLE audit_events (
id bigint NOT NULL, id bigint NOT NULL,
author_id integer NOT NULL, author_id integer NOT NULL,
...@@ -19415,9 +19405,7 @@ CREATE SEQUENCE system_note_metadata_id_seq ...@@ -19415,9 +19405,7 @@ CREATE SEQUENCE system_note_metadata_id_seq
ALTER SEQUENCE system_note_metadata_id_seq OWNED BY system_note_metadata.id; ALTER SEQUENCE system_note_metadata_id_seq OWNED BY system_note_metadata.id;
CREATE TABLE taggings ( CREATE TABLE taggings (
id_convert_to_bigint integer DEFAULT 0 NOT NULL,
tag_id integer, tag_id integer,
taggable_id_convert_to_bigint integer,
taggable_type character varying, taggable_type character varying,
tagger_id integer, tagger_id integer,
tagger_type character varying, tagger_type character varying,
...@@ -27344,8 +27332,6 @@ ALTER INDEX product_analytics_events_experimental_pkey ATTACH PARTITION gitlab_p ...@@ -27344,8 +27332,6 @@ ALTER INDEX product_analytics_events_experimental_pkey ATTACH PARTITION gitlab_p
CREATE TRIGGER trigger_91dc388a5fe6 BEFORE INSERT OR UPDATE ON dep_ci_build_trace_sections FOR EACH ROW EXECUTE FUNCTION trigger_91dc388a5fe6(); CREATE TRIGGER trigger_91dc388a5fe6 BEFORE INSERT OR UPDATE ON dep_ci_build_trace_sections FOR EACH ROW EXECUTE FUNCTION trigger_91dc388a5fe6();
CREATE TRIGGER trigger_aebe8b822ad3 BEFORE INSERT OR UPDATE ON taggings FOR EACH ROW EXECUTE FUNCTION trigger_aebe8b822ad3();
CREATE TRIGGER trigger_delete_project_namespace_on_project_delete AFTER DELETE ON projects FOR EACH ROW WHEN ((old.project_namespace_id IS NOT NULL)) EXECUTE FUNCTION delete_associated_project_namespace(); CREATE TRIGGER trigger_delete_project_namespace_on_project_delete AFTER DELETE ON projects FOR EACH ROW WHEN ((old.project_namespace_id IS NOT NULL)) EXECUTE FUNCTION delete_associated_project_namespace();
CREATE TRIGGER trigger_has_external_issue_tracker_on_delete AFTER DELETE ON integrations FOR EACH ROW WHEN ((((old.category)::text = 'issue_tracker'::text) AND (old.active = true) AND (old.project_id IS NOT NULL))) EXECUTE FUNCTION set_has_external_issue_tracker(); CREATE TRIGGER trigger_has_external_issue_tracker_on_delete AFTER DELETE ON integrations FOR EACH ROW WHEN ((((old.category)::text = 'issue_tracker'::text) AND (old.active = true) AND (old.project_id IS NOT NULL))) EXECUTE FUNCTION set_has_external_issue_tracker();
# frozen_string_literal: true
require 'spec_helper'
require_migration!('drop_temporary_columns_and_triggers_for_taggings')
RSpec.describe DropTemporaryColumnsAndTriggersForTaggings do
let(:taggings_table) { table(:taggings) }
it 'correctly migrates up and down' do
reversible_migration do |migration|
migration.before -> {
expect(taggings_table.column_names).to include('id_convert_to_bigint')
expect(taggings_table.column_names).to include('taggable_id_convert_to_bigint')
}
migration.after -> {
taggings_table.reset_column_information
expect(taggings_table.column_names).not_to include('id_convert_to_bigint')
expect(taggings_table.column_names).not_to include('taggable_id_convert_to_bigint')
}
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment