diff options
Diffstat (limited to 'db/post_migrate/20231017064317_swap_columns_for_ci_pipeline_variables_pipeline_id_bigint.rb')
-rw-r--r-- | db/post_migrate/20231017064317_swap_columns_for_ci_pipeline_variables_pipeline_id_bigint.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/db/post_migrate/20231017064317_swap_columns_for_ci_pipeline_variables_pipeline_id_bigint.rb b/db/post_migrate/20231017064317_swap_columns_for_ci_pipeline_variables_pipeline_id_bigint.rb new file mode 100644 index 00000000000..155608a6879 --- /dev/null +++ b/db/post_migrate/20231017064317_swap_columns_for_ci_pipeline_variables_pipeline_id_bigint.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +class SwapColumnsForCiPipelineVariablesPipelineIdBigint < Gitlab::Database::Migration[2.1] + include ::Gitlab::Database::MigrationHelpers::Swapping + disable_ddl_transaction! + + def up + swap + end + + def down + swap + end + + private + + def swap + # rubocop:disable Migration/WithLockRetriesDisallowedMethod + with_lock_retries(raise_on_exhaustion: true) do + lock_tables(:ci_pipelines, :ci_pipeline_variables) + + swap_columns( + :ci_pipeline_variables, + :pipeline_id, + :pipeline_id_convert_to_bigint + ) + reset_trigger_function(:trigger_7f3d66a7d7f5) + swap_columns_default( + :ci_pipeline_variables, + :pipeline_id, + :pipeline_id_convert_to_bigint + ) + swap_foreign_keys( + :ci_pipeline_variables, + :fk_f29c5f4380, + :temp_fk_rails_8d3b04e3e1 + ) + swap_indexes( + :ci_pipeline_variables, + :index_ci_pipeline_variables_on_pipeline_id_and_key, + :index_ci_pipeline_variables_on_pipeline_id_bigint_and_key + ) + end + # rubocop:enable Migration/WithLockRetriesDisallowedMethod + end +end |