diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-25 21:10:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-25 21:10:42 +0300 |
commit | a880341a7b3a164ba381620852cc3ea0777f67ad (patch) | |
tree | de7f7a09aee296eef7924cad7eb7ec2e9ea29ce0 /db | |
parent | a8c1bc6f757ecacbc3481e52a3f4cefb6c6db5fd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
7 files changed, 92 insertions, 1 deletions
diff --git a/db/migrate/20210519132109_initialize_conversion_of_ci_builds_metadata_to_bigint.rb b/db/migrate/20210519132109_initialize_conversion_of_ci_builds_metadata_to_bigint.rb new file mode 100644 index 00000000000..7ff0276b4b5 --- /dev/null +++ b/db/migrate/20210519132109_initialize_conversion_of_ci_builds_metadata_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfCiBuildsMetadataToBigint < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + TABLE = :ci_builds_metadata + COLUMN = :build_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 diff --git a/db/post_migrate/20210519132129_backfill_ci_builds_metadata_for_bigint_conversion.rb b/db/post_migrate/20210519132129_backfill_ci_builds_metadata_for_bigint_conversion.rb new file mode 100644 index 00000000000..3aeabbcc0ad --- /dev/null +++ b/db/post_migrate/20210519132129_backfill_ci_builds_metadata_for_bigint_conversion.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class BackfillCiBuildsMetadataForBigintConversion < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + TABLE = :ci_builds_metadata + COLUMN = :build_id + + def up + backfill_conversion_of_integer_to_bigint TABLE, COLUMN, batch_size: 15000, sub_batch_size: 100 + end + + def down + revert_backfill_conversion_of_integer_to_bigint TABLE, COLUMN + end +end diff --git a/db/post_migrate/20210520012430_backfill_pk_conversion_for_self_managed.rb b/db/post_migrate/20210520012430_backfill_pk_conversion_for_self_managed.rb new file mode 100644 index 00000000000..d554b412420 --- /dev/null +++ b/db/post_migrate/20210520012430_backfill_pk_conversion_for_self_managed.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +class BackfillPkConversionForSelfManaged < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + CONVERSIONS = [ + { table: :events, columns: %i(id), sub_batch_size: 500 }, + { table: :push_event_payloads, columns: %i(event_id), sub_batch_size: 2500, primary_key: :event_id }, + { table: :ci_job_artifacts, columns: %i(id job_id), sub_batch_size: 2000 }, + { table: :ci_sources_pipelines, columns: %i(source_job_id), sub_batch_size: 100 }, + { table: :ci_build_needs, columns: %i(build_id), sub_batch_size: 1000 }, + { table: :ci_builds, columns: %i(id stage_id), sub_batch_size: 250 }, + { table: :ci_builds_runner_session, columns: %i(build_id), sub_batch_size: 5000 }, + { table: :ci_build_trace_chunks, columns: %i(build_id), sub_batch_size: 1000 } + ] + + def up + return unless should_run? + + CONVERSIONS.each do |conversion| + backfill_conversion_of_integer_to_bigint( + conversion[:table], conversion[:columns], + sub_batch_size: conversion[:sub_batch_size], primary_key: conversion.fetch(:primary_key, :id) + ) + end + end + + def down + return unless should_run? + + CONVERSIONS.each do |conversion| + revert_backfill_conversion_of_integer_to_bigint( + conversion[:table], conversion[:columns], + primary_key: conversion.fetch(:primary_key, :id) + ) + end + end + + private + + def should_run? + !Gitlab.com? + end +end diff --git a/db/schema_migrations/20210519132109 b/db/schema_migrations/20210519132109 new file mode 100644 index 00000000000..9d8537aa6b2 --- /dev/null +++ b/db/schema_migrations/20210519132109 @@ -0,0 +1 @@ +ba464ad09f3cec0e9cf94b3041ad946e3a5a8c915ce0b9f4f95ab49cb55d305d
\ No newline at end of file diff --git a/db/schema_migrations/20210519132129 b/db/schema_migrations/20210519132129 new file mode 100644 index 00000000000..da7a8212092 --- /dev/null +++ b/db/schema_migrations/20210519132129 @@ -0,0 +1 @@ +8041e898177bdee3b4d1ad82ec7dd3b79cb7dd740f773cd91dc4306a87a397fd
\ No newline at end of file diff --git a/db/schema_migrations/20210520012430 b/db/schema_migrations/20210520012430 new file mode 100644 index 00000000000..d92bc8d8369 --- /dev/null +++ b/db/schema_migrations/20210520012430 @@ -0,0 +1 @@ +86b9f1c0f4288bf83e8b2d70b06b8951b7bcef0aa9324d9546471f6f094b014b
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 8bfe5e16f41..7e2a540c6f1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -152,6 +152,15 @@ BEGIN END; $$; +CREATE FUNCTION trigger_8487d4de3e7b() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + NEW."build_id_convert_to_bigint" := NEW."build_id"; + RETURN NEW; +END; +$$; + CREATE FUNCTION trigger_91dc388a5fe6() RETURNS trigger LANGUAGE plpgsql AS $$ @@ -10585,7 +10594,8 @@ CREATE TABLE ci_builds_metadata ( has_exposed_artifacts boolean, environment_auto_stop_in character varying(255), expanded_environment_name character varying(255), - secrets jsonb DEFAULT '{}'::jsonb NOT NULL + secrets jsonb DEFAULT '{}'::jsonb NOT NULL, + build_id_convert_to_bigint bigint DEFAULT 0 NOT NULL ); CREATE SEQUENCE ci_builds_metadata_id_seq @@ -25249,6 +25259,8 @@ CREATE TRIGGER trigger_69523443cc10 BEFORE INSERT OR UPDATE ON events FOR EACH R CREATE TRIGGER trigger_8485e97c00e3 BEFORE INSERT OR UPDATE ON ci_sources_pipelines FOR EACH ROW EXECUTE FUNCTION trigger_8485e97c00e3(); +CREATE TRIGGER trigger_8487d4de3e7b BEFORE INSERT OR UPDATE ON ci_builds_metadata FOR EACH ROW EXECUTE FUNCTION trigger_8487d4de3e7b(); + CREATE TRIGGER trigger_91dc388a5fe6 BEFORE INSERT OR UPDATE ON ci_build_trace_sections FOR EACH ROW EXECUTE FUNCTION trigger_91dc388a5fe6(); CREATE TRIGGER trigger_be1804f21693 BEFORE INSERT OR UPDATE ON ci_job_artifacts FOR EACH ROW EXECUTE FUNCTION trigger_be1804f21693(); |