Commit a0440f62 authored by Yannis Roussos's avatar Yannis Roussos

Merge branch '328435-convert-ci-sources-pipelines-to-bigint' into 'master'

Initialize conversion of ci_sources_pipelines.source_job_id to bigint

See merge request gitlab-org/gitlab!59951
parents 00ec9b69 ee029c73
---
title: Initialize conversion of ci_sources_pipelines.source_job_id to bigint
merge_request: 59951
author:
type: other
# frozen_string_literal: true
class InitializeConversionOfCiSourcesPipelinesSourceJobIdToBigint < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
def up
# Foreign key that references ci_builds.id
initialize_conversion_of_integer_to_bigint :ci_sources_pipelines, :source_job_id
end
def down
trigger_name = rename_trigger_name(:ci_sources_pipelines, :source_job_id, :source_job_id_convert_to_bigint)
remove_rename_triggers_for_postgresql :ci_sources_pipelines, trigger_name
remove_column :ci_sources_pipelines, :source_job_id_convert_to_bigint
end
end
# frozen_string_literal: true
class BackfillCiSourcesPipelinesSourceJobIdForBigintConversion < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
def up
return unless should_run?
backfill_conversion_of_integer_to_bigint :ci_sources_pipelines, :source_job_id,
batch_size: 15000, sub_batch_size: 100
end
def down
return unless should_run?
Gitlab::Database::BackgroundMigration::BatchedMigration
.where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob')
.where(table_name: 'ci_sources_pipelines', column_name: 'id')
.where('job_arguments = ?', [%w[source_job_id], %w[source_job_id_convert_to_bigint]].to_json)
.delete_all
end
private
def should_run?
Gitlab.dev_or_test_env? || Gitlab.com?
end
end
d0119a45e6ab08afa6ed73a248b81cae4a4de63d46fda25968444256355d208f
\ No newline at end of file
e588b2e6c612e4a25615d9c5179100af20d3507e0eec8feba52bc6b45d9befea
\ No newline at end of file
...@@ -115,6 +115,15 @@ BEGIN ...@@ -115,6 +115,15 @@ BEGIN
END; END;
$$; $$;
CREATE FUNCTION trigger_8485e97c00e3() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW."source_job_id_convert_to_bigint" := NEW."source_job_id";
RETURN NEW;
END;
$$;
CREATE FUNCTION trigger_be1804f21693() RETURNS trigger CREATE FUNCTION trigger_be1804f21693() RETURNS trigger
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
...@@ -10977,7 +10986,8 @@ CREATE TABLE ci_sources_pipelines ( ...@@ -10977,7 +10986,8 @@ CREATE TABLE ci_sources_pipelines (
pipeline_id integer, pipeline_id integer,
source_project_id integer, source_project_id integer,
source_job_id integer, source_job_id integer,
source_pipeline_id integer source_pipeline_id integer,
source_job_id_convert_to_bigint bigint
); );
CREATE SEQUENCE ci_sources_pipelines_id_seq CREATE SEQUENCE ci_sources_pipelines_id_seq
...@@ -24703,6 +24713,8 @@ CREATE TRIGGER trigger_07c94931164e BEFORE INSERT OR UPDATE ON push_event_payloa ...@@ -24703,6 +24713,8 @@ CREATE TRIGGER trigger_07c94931164e BEFORE INSERT OR UPDATE ON push_event_payloa
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_be1804f21693 BEFORE INSERT OR UPDATE ON ci_job_artifacts FOR EACH ROW EXECUTE PROCEDURE trigger_be1804f21693(); CREATE TRIGGER trigger_be1804f21693 BEFORE INSERT OR UPDATE ON ci_job_artifacts FOR EACH ROW EXECUTE PROCEDURE trigger_be1804f21693();
CREATE TRIGGER trigger_has_external_issue_tracker_on_delete AFTER DELETE ON services FOR EACH ROW WHEN ((((old.category)::text = 'issue_tracker'::text) AND (old.active = true) AND (old.project_id IS NOT NULL))) EXECUTE PROCEDURE set_has_external_issue_tracker(); CREATE TRIGGER trigger_has_external_issue_tracker_on_delete AFTER DELETE ON services FOR EACH ROW WHEN ((((old.category)::text = 'issue_tracker'::text) AND (old.active = true) AND (old.project_id IS NOT NULL))) EXECUTE PROCEDURE set_has_external_issue_tracker();
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