summaryrefslogtreecommitdiff
path: root/db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb
blob: d6ef6509fff450c89f83b6988a09d4a79d348926 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class AddMarkForDeletionIndexesToProjects < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_foreign_key :projects, :users, column: :marked_for_deletion_by_user_id, on_delete: :nullify
    add_concurrent_index :projects, :marked_for_deletion_by_user_id, where: 'marked_for_deletion_by_user_id IS NOT NULL'
  end

  def down
    remove_foreign_key_if_exists :projects, column: :marked_for_deletion_by_user_id
    remove_concurrent_index :projects, :marked_for_deletion_by_user_id
  end
end