Commit 53e53b2a authored by Yannis Roussos's avatar Yannis Roussos

Merge branch 'ab/ci_job_artifacts' into 'master'

Start backfill for primary key conversion to int8 for ci_job_artifacts

See merge request gitlab-org/gitlab!59786
parents fbb97373 b96687bf
---
title: Initialize int8 migration for ci_job_artifacts
merge_request: 59786
author:
type: other
# frozen_string_literal: true
class InitializeConversionOfCiJobArtifactsToBigint < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
TABLE = :ci_job_artifacts
COLUMNS = %i(id job_id)
TARGET_COLUMNS = COLUMNS.map { |col| "#{col}_convert_to_bigint" }
def up
initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
trigger_name = rename_trigger_name(TABLE, COLUMNS, TARGET_COLUMNS)
remove_rename_triggers_for_postgresql TABLE, trigger_name
TARGET_COLUMNS.each do |column|
remove_column TABLE, column
end
end
end
# frozen_string_literal: true
class BackfillConversionOfCiJobArtifacts < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
return unless should_run?
backfill_conversion_of_integer_to_bigint :ci_job_artifacts, %i(id 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_job_artifacts', column_name: 'id')
.where('job_arguments = ?', [%w[id job_id], %w[id_convert_to_bigint job_id_convert_to_bigint]].to_json)
.delete_all
end
private
def should_run?
Gitlab.dev_or_test_env? || Gitlab.com?
end
end
5404ecd22f943671c076b0e870a487ec822cb3d594c223ad4db5b1584394ceb6
\ No newline at end of file
58cd21a02a395564acf9abcc39c3daafc5db90aa0b3f29133644f21bb669cdf6
\ No newline at end of file
......@@ -115,6 +115,16 @@ BEGIN
END;
$$;
CREATE FUNCTION trigger_be1804f21693() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW."id_convert_to_bigint" := NEW."id";
NEW."job_id_convert_to_bigint" := NEW."job_id";
RETURN NEW;
END;
$$;
CREATE TABLE audit_events (
id bigint NOT NULL,
author_id integer NOT NULL,
......@@ -10572,6 +10582,8 @@ CREATE TABLE ci_job_artifacts (
file_sha256 bytea,
file_format smallint,
file_location smallint,
id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
job_id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
CONSTRAINT check_27f0f6dbab CHECK ((file_store IS NOT NULL))
);
......@@ -24664,6 +24676,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_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_insert AFTER INSERT ON services FOR EACH ROW WHEN ((((new.category)::text = 'issue_tracker'::text) AND (new.active = true) AND (new.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