Commit 4bcbf379 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Prepare taggings table for bigint conversion

Adds bigint column and triggers to prepare for bigint conversion

Changelog: other
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62205
parent 3a95b615
...@@ -9,3 +9,7 @@ ActsAsTaggableOn.tags_counter = false ...@@ -9,3 +9,7 @@ ActsAsTaggableOn.tags_counter = false
# validate that counter cache is disabled # validate that counter cache is disabled
raise "Counter cache is not disabled" if 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.ignore_column :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.2', remove_after: '2021-08-22'
# frozen_string_literal: true
class InitializeConversionOfTaggingsToBigint < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
TABLE = :taggings
COLUMNS = %i(id taggable_id)
def up
initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
end
# frozen_string_literal: true
class BackfillTaggingsForBigintConversion < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
TABLE = :taggings
COLUMNS = %i(id taggable_id)
def up
backfill_conversion_of_integer_to_bigint TABLE, COLUMNS, batch_size: 15000, sub_batch_size: 100
end
def down
revert_backfill_conversion_of_integer_to_bigint TABLE, COLUMNS
end
end
eddbcd18c17f9017a2cdfb6fc0144dcfcb539d3617271722b2918bdbe48c481a
\ No newline at end of file
3ee15db28406522a5fb591395dd3d4a46b10e958339dc60ded3751e23096864d
\ No newline at end of file
...@@ -161,6 +161,16 @@ BEGIN ...@@ -161,6 +161,16 @@ 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 FUNCTION trigger_be1804f21693() RETURNS trigger CREATE FUNCTION trigger_be1804f21693() RETURNS trigger
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
...@@ -18207,7 +18217,9 @@ CREATE TABLE taggings ( ...@@ -18207,7 +18217,9 @@ CREATE TABLE taggings (
tagger_id integer, tagger_id integer,
tagger_type character varying, tagger_type character varying,
context character varying, context character varying,
created_at timestamp without time zone created_at timestamp without time zone,
id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
taggable_id_convert_to_bigint bigint
); );
CREATE SEQUENCE taggings_id_seq CREATE SEQUENCE taggings_id_seq
...@@ -25250,6 +25262,8 @@ CREATE TRIGGER trigger_8485e97c00e3 BEFORE INSERT OR UPDATE ON ci_sources_pipeli ...@@ -25250,6 +25262,8 @@ CREATE TRIGGER trigger_8485e97c00e3 BEFORE INSERT OR UPDATE ON ci_sources_pipeli
CREATE TRIGGER trigger_91dc388a5fe6 BEFORE INSERT OR UPDATE ON ci_build_trace_sections FOR EACH ROW EXECUTE FUNCTION trigger_91dc388a5fe6(); CREATE TRIGGER trigger_91dc388a5fe6 BEFORE INSERT OR UPDATE ON 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_be1804f21693 BEFORE INSERT OR UPDATE ON ci_job_artifacts FOR EACH ROW EXECUTE FUNCTION trigger_be1804f21693(); CREATE TRIGGER trigger_be1804f21693 BEFORE INSERT OR UPDATE ON ci_job_artifacts FOR EACH ROW EXECUTE FUNCTION trigger_be1804f21693();
CREATE TRIGGER trigger_cf2f9e35f002 BEFORE INSERT OR UPDATE ON ci_build_trace_chunks FOR EACH ROW EXECUTE FUNCTION trigger_cf2f9e35f002(); CREATE TRIGGER trigger_cf2f9e35f002 BEFORE INSERT OR UPDATE ON ci_build_trace_chunks FOR EACH ROW EXECUTE FUNCTION trigger_cf2f9e35f002();
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