Commit b90bc5ad authored by huzaifaiftikhar1's avatar huzaifaiftikhar1 Committed by Huzaifa Iftikhar

Add RSpecs and make the where condition in migration inline

parent cec0d009
......@@ -6,9 +6,7 @@ class AddIndexToProjectsOnMarkedForDeletionAt < Gitlab::Database::Migration[1.0]
INDEX_NAME = 'index_projects_not_aimed_for_deletion'
def up
marked_for_deletion_is_null = 'marked_for_deletion_at IS NULL'
add_concurrent_index :projects, :marked_for_deletion_at, where: marked_for_deletion_is_null, name: INDEX_NAME
add_concurrent_index :projects, :marked_for_deletion_at, where: 'marked_for_deletion_at IS NULL', name: INDEX_NAME
end
def down
......
# 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