Commit f9a40430 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'ab/migrate-ci-builds' into 'master'

Initialize int8 migration for ci_builds

See merge request gitlab-org/gitlab!60265
parents 4cea463b d6fcc60d
...@@ -62,6 +62,9 @@ module Ci ...@@ -62,6 +62,9 @@ module Ci
delegate :gitlab_deploy_token, to: :project delegate :gitlab_deploy_token, to: :project
delegate :trigger_short_token, to: :trigger_request, allow_nil: true delegate :trigger_short_token, to: :trigger_request, allow_nil: true
ignore_columns :id_convert_to_bigint, remove_with: '14.1', remove_after: '2021-07-22'
ignore_columns :stage_id_convert_to_bigint, remove_with: '14.1', remove_after: '2021-07-22'
## ##
# Since Gitlab 11.5, deployments records started being created right after # Since Gitlab 11.5, deployments records started being created right after
# `ci_builds` creation. We can look up a relevant `environment` through # `ci_builds` creation. We can look up a relevant `environment` through
......
---
title: Initialize int8 migration for ci_builds
merge_request: 60265
author:
type: other
# frozen_string_literal: true
class InitializeConversionOfCiBuildsToBigint < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
TABLE = :ci_builds
COLUMNS = %i(id stage_id)
TARGET_COLUMNS = COLUMNS.map { |col| "#{col}_convert_to_bigint" }
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 BackfillCiBuildsForBigintConversion < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
TABLE = :ci_builds
COLUMNS = %i(id stage_id).freeze
def up
return unless should_run?
backfill_conversion_of_integer_to_bigint TABLE, COLUMNS, batch_size: 15000, sub_batch_size: 100
end
def down
return unless should_run?
revert_backfill_conversion_of_integer_to_bigint TABLE, COLUMNS
end
private
def should_run?
Gitlab.dev_or_test_env? || Gitlab.com?
end
end
46de2e905a591c14ce18acf041bac6fb48ec19ad9f40fababcbf27ae02f7fa75
\ No newline at end of file
12ad8f05a4d864d9986d6ca400a687c40b2de1acb461b134a8103f9a882921e7
\ No newline at end of file
...@@ -115,6 +115,16 @@ BEGIN ...@@ -115,6 +115,16 @@ BEGIN
END; END;
$$; $$;
CREATE FUNCTION trigger_3f6129be01d2() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW."id_convert_to_bigint" := NEW."id";
NEW."stage_id_convert_to_bigint" := NEW."stage_id";
RETURN NEW;
END;
$$;
CREATE FUNCTION trigger_69523443cc10() RETURNS trigger CREATE FUNCTION trigger_69523443cc10() RETURNS trigger
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
...@@ -10433,6 +10443,8 @@ CREATE TABLE ci_builds ( ...@@ -10433,6 +10443,8 @@ CREATE TABLE ci_builds (
waiting_for_resource_at timestamp with time zone, waiting_for_resource_at timestamp with time zone,
processed boolean, processed boolean,
scheduling_type smallint, scheduling_type smallint,
id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
stage_id_convert_to_bigint bigint,
CONSTRAINT check_1e2fbd1b39 CHECK ((lock_version IS NOT NULL)) CONSTRAINT check_1e2fbd1b39 CHECK ((lock_version IS NOT NULL))
); );
...@@ -24754,6 +24766,8 @@ CREATE TRIGGER trigger_07c94931164e BEFORE INSERT OR UPDATE ON push_event_payloa ...@@ -24754,6 +24766,8 @@ CREATE TRIGGER trigger_07c94931164e BEFORE INSERT OR UPDATE ON push_event_payloa
CREATE TRIGGER trigger_21e7a2602957 BEFORE INSERT OR UPDATE ON ci_build_needs FOR EACH ROW EXECUTE PROCEDURE trigger_21e7a2602957(); CREATE TRIGGER trigger_21e7a2602957 BEFORE INSERT OR UPDATE ON ci_build_needs FOR EACH ROW EXECUTE PROCEDURE trigger_21e7a2602957();
CREATE TRIGGER trigger_3f6129be01d2 BEFORE INSERT OR UPDATE ON ci_builds FOR EACH ROW EXECUTE PROCEDURE trigger_3f6129be01d2();
CREATE TRIGGER trigger_69523443cc10 BEFORE INSERT OR UPDATE ON events FOR EACH ROW EXECUTE PROCEDURE trigger_69523443cc10(); CREATE TRIGGER trigger_69523443cc10 BEFORE INSERT OR UPDATE ON events FOR EACH ROW EXECUTE PROCEDURE trigger_69523443cc10();
CREATE TRIGGER trigger_8485e97c00e3 BEFORE INSERT OR UPDATE ON ci_sources_pipelines FOR EACH ROW EXECUTE PROCEDURE trigger_8485e97c00e3(); CREATE TRIGGER trigger_8485e97c00e3 BEFORE INSERT OR UPDATE ON ci_sources_pipelines FOR EACH ROW EXECUTE PROCEDURE trigger_8485e97c00e3();
...@@ -261,6 +261,8 @@ excluded_attributes: ...@@ -261,6 +261,8 @@ excluded_attributes:
- :resource_group_id - :resource_group_id
- :waiting_for_resource_at - :waiting_for_resource_at
- :processed - :processed
- :id_convert_to_bigint
- :stage_id_convert_to_bigint
sentry_issue: sentry_issue:
- :issue_id - :issue_id
push_event_payload: push_event_payload:
......
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