Commit 2021ffbb authored by Tiger Watson's avatar Tiger Watson

Merge branch '344013_index_projects_on_marked_for_deletion_at' into 'master'

Add index to projects on marked_for_deletion_at field is null

See merge request gitlab-org/gitlab!75888
parents c1f3d5e8 8d942cb1
# frozen_string_literal: true
class AddIndexToProjectsOnMarkedForDeletionAt < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
INDEX_NAME = 'index_projects_not_aimed_for_deletion'
def up
add_concurrent_index :projects, :id, where: 'marked_for_deletion_at IS NULL', name: INDEX_NAME
end
def down
remove_concurrent_index :projects, :id, name: INDEX_NAME
end
end
9954fb041a3f284f53cc9c5c68b1a9dff36513a1851e663c221eccd40736fb16
\ No newline at end of file
......@@ -27106,6 +27106,8 @@ CREATE INDEX index_projects_api_vis20_path ON projects USING btree (path, id) WH
CREATE INDEX index_projects_api_vis20_updated_at ON projects USING btree (updated_at, id) WHERE (visibility_level = 20);
CREATE INDEX index_projects_not_aimed_for_deletion ON projects USING btree (id) WHERE (marked_for_deletion_at IS NULL);
CREATE INDEX index_projects_on_created_at_and_id ON projects USING btree (created_at, id);
CREATE INDEX index_projects_on_creator_id_and_created_at_and_id ON projects USING btree (creator_id, created_at, id);
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe AddIndexToProjectsOnMarkedForDeletionAt do
it 'correctly migrates up and down' do
reversible_migration do |migration|
migration.before -> {
expect(ActiveRecord::Base.connection.indexes('projects').map(&:name)).not_to include('index_projects_not_aimed_for_deletion')
}
migration.after -> {
expect(ActiveRecord::Base.connection.indexes('projects').map(&:name)).to include('index_projects_not_aimed_for_deletion')
}
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