Skip to content
Snippets Groups Projects
Verified Commit 09fcf24f authored by Tianwen Chen's avatar Tianwen Chen :two: Committed by GitLab
Browse files

Initialize bigint conversion for merge_trains

This is the first step to convert pipeline_id related to bigint for:
- merge_trains.pipeline_id

See https://docs.gitlab.com/ee/development/database/avoiding_downtime_in_migrations.html#initialize-the-conversion-and-start-migrating-existing-data-release-n

Changelog: added
parent b1b109d8
No related branches found
No related tags found
1 merge request!148786Initialize bigint conversion for merge_trains
# frozen_string_literal: true
class InitConversionForMergeTrainsPipelineIdBigint < Gitlab::Database::Migration[2.2]
disable_ddl_transaction!
milestone '16.11'
TABLE = :merge_trains
COLUMN = :pipeline_id
def up
initialize_conversion_of_integer_to_bigint(TABLE, COLUMN)
end
def down
revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMN)
end
end
# frozen_string_literal: true
class BackfillMergeTrainsPipelineIdBigint < Gitlab::Database::Migration[2.2]
restrict_gitlab_migration gitlab_schema: :gitlab_main
milestone '16.11'
TABLE = :merge_trains
COLUMN = :pipeline_id
def up
backfill_conversion_of_integer_to_bigint(TABLE, COLUMN)
end
def down
revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMN)
end
end
db237e66d5a4e215c5959b14815fe658ce2f0f10894f1a052b0b6946b5455670
\ No newline at end of file
9941d3b5393aefbe47607af58f1b39c2eb7951ff01ccc91da51c37af6d8b8a31
\ No newline at end of file
......@@ -668,6 +668,15 @@ BEGIN
END;
$$;
 
CREATE FUNCTION trigger_3857ca5ea4af() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW."pipeline_id_convert_to_bigint" := NEW."pipeline_id";
RETURN NEW;
END;
$$;
CREATE FUNCTION trigger_388e93f88fdd() RETURNS trigger
LANGUAGE plpgsql
AS $$
......@@ -11345,7 +11354,8 @@ CREATE TABLE merge_trains (
target_branch text NOT NULL,
status smallint DEFAULT 0 NOT NULL,
merged_at timestamp with time zone,
duration integer
duration integer,
pipeline_id_convert_to_bigint bigint
);
 
CREATE SEQUENCE merge_trains_id_seq
......@@ -29614,6 +29624,8 @@ CREATE TRIGGER trigger_10ee1357e825 BEFORE INSERT OR UPDATE ON p_ci_builds FOR E
 
CREATE TRIGGER trigger_2428b5519042 BEFORE INSERT OR UPDATE ON vulnerability_feedback FOR EACH ROW EXECUTE FUNCTION trigger_2428b5519042();
 
CREATE TRIGGER trigger_3857ca5ea4af BEFORE INSERT OR UPDATE ON merge_trains FOR EACH ROW EXECUTE FUNCTION trigger_3857ca5ea4af();
CREATE TRIGGER trigger_388e93f88fdd BEFORE INSERT OR UPDATE ON packages_build_infos FOR EACH ROW EXECUTE FUNCTION trigger_388e93f88fdd();
 
CREATE TRIGGER trigger_b2d852e1e2cb BEFORE INSERT OR UPDATE ON ci_pipelines FOR EACH ROW EXECUTE FUNCTION trigger_b2d852e1e2cb();
......@@ -5,6 +5,9 @@ module MergeTrains
class Car < ApplicationRecord
include Gitlab::Utils::StrongMemoize
include AfterCommitQueue
include IgnorableColumns
ignore_columns :pipeline_id_convert_to_bigint, remove_with: '17.1', remove_after: '2024-06-14'
# For legacy reasons, each row is a merge train in the database
self.table_name = 'merge_trains'
......
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