diff options
Diffstat (limited to 'db/post_migrate/20210819145000_drop_temporary_columns_and_triggers_for_ci_builds_runner_session.rb')
-rw-r--r-- | db/post_migrate/20210819145000_drop_temporary_columns_and_triggers_for_ci_builds_runner_session.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/db/post_migrate/20210819145000_drop_temporary_columns_and_triggers_for_ci_builds_runner_session.rb b/db/post_migrate/20210819145000_drop_temporary_columns_and_triggers_for_ci_builds_runner_session.rb new file mode 100644 index 00000000000..bbcee556020 --- /dev/null +++ b/db/post_migrate/20210819145000_drop_temporary_columns_and_triggers_for_ci_builds_runner_session.rb @@ -0,0 +1,28 @@ +# 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 |