Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20230323131521_remove_machine_id_from_builds_metadata.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 41d23735807957ed85467d8ecfd7e90b904fdb0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

class RemoveMachineIdFromBuildsMetadata < Gitlab::Database::Migration[2.1]
  include Gitlab::Database::PartitioningMigrationHelpers

  disable_ddl_transaction!

  INDEX_NAME = 'p_ci_builds_metadata_on_runner_machine_id_idx'

  def up
    with_lock_retries do
      remove_column :p_ci_builds_metadata, :runner_machine_id, if_exists: true
    end
  end

  def down
    add_column :p_ci_builds_metadata, :runner_machine_id, :bigint, if_not_exists: true

    add_concurrent_partitioned_index :p_ci_builds_metadata, :runner_machine_id, name: INDEX_NAME,
      where: 'runner_machine_id IS NOT NULL'
  end
end