Commit c1e312d9 authored by Patrick Bair's avatar Patrick Bair

Merge branch...

Merge branch '338057-address-the-primary-key-overflow-risk-for-the-ci_builds_runner_session-table-step-3-drop' into 'master'

Resolve "Address the Primary Key Overflow risk for the ci_builds_runner_session table - Step 3: Drop temporary columns and triggers"

See merge request gitlab-org/gitlab!68542
parents 58a5c889 80011243
# frozen_string_literal: true
class DropTemporaryColumnsAndTriggersForCiBuildsRunnerSession < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
TABLE = 'ci_builds_runner_session'
TEMPORARY_COLUMN = 'build_id_convert_to_bigint'
MAIN_COLUMN = 'build_id'
# rubocop:disable Migration/WithLockRetriesDisallowedMethod
def up
with_lock_retries do
cleanup_conversion_of_integer_to_bigint(TABLE, MAIN_COLUMN)
end
end
def down
check_trigger_permissions!(TABLE)
with_lock_retries do
add_column(TABLE, TEMPORARY_COLUMN, :int, default: 0, null: false)
install_rename_triggers(TABLE, MAIN_COLUMN, TEMPORARY_COLUMN)
end
end
# rubocop:enable Migration/WithLockRetriesDisallowedMethod
end
a73a33d30af332c8c01cd9d55618a1b84bc9074ffe4d06fd72c8eb37cd264954
\ No newline at end of file
......@@ -71,15 +71,6 @@ BEGIN
END;
$$;
CREATE FUNCTION trigger_51ab7cef8934() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW."build_id_convert_to_bigint" := NEW."build_id";
RETURN NEW;
END;
$$;
CREATE FUNCTION trigger_542d6c2ad72e() RETURNS trigger
LANGUAGE plpgsql
AS $$
......@@ -11396,7 +11387,6 @@ ALTER SEQUENCE ci_builds_metadata_id_seq OWNED BY ci_builds_metadata.id;
CREATE TABLE ci_builds_runner_session (
id bigint NOT NULL,
build_id_convert_to_bigint integer DEFAULT 0 NOT NULL,
url character varying NOT NULL,
certificate character varying,
"authorization" character varying,
......@@ -27289,8 +27279,6 @@ CREATE TRIGGER trigger_21e7a2602957 BEFORE INSERT OR UPDATE ON ci_build_needs FO
CREATE TRIGGER trigger_3f6129be01d2 BEFORE INSERT OR UPDATE ON ci_builds FOR EACH ROW EXECUTE FUNCTION trigger_3f6129be01d2();
CREATE TRIGGER trigger_51ab7cef8934 BEFORE INSERT OR UPDATE ON ci_builds_runner_session FOR EACH ROW EXECUTE FUNCTION trigger_51ab7cef8934();
CREATE TRIGGER trigger_542d6c2ad72e BEFORE INSERT OR UPDATE ON ci_builds_metadata FOR EACH ROW EXECUTE FUNCTION trigger_542d6c2ad72e();
CREATE TRIGGER trigger_8487d4de3e7b BEFORE INSERT OR UPDATE ON ci_builds_metadata FOR EACH ROW EXECUTE FUNCTION trigger_8487d4de3e7b();
# frozen_string_literal: true
require 'spec_helper'
require_migration!('drop_temporary_columns_and_triggers_for_ci_builds_runner_session')
RSpec.describe DropTemporaryColumnsAndTriggersForCiBuildsRunnerSession, :migration do
let(:ci_builds_runner_session_table) { table(:ci_builds_runner_session) }
it 'correctly migrates up and down' do
reversible_migration do |migration|
migration.before -> {
expect(ci_builds_runner_session_table.column_names).to include('build_id_convert_to_bigint')
}
migration.after -> {
ci_builds_runner_session_table.reset_column_information
expect(ci_builds_runner_session_table.column_names).not_to include('build_id_convert_to_bigint')
}
end
end
end
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