class AddStockItemUniqueIndex < ActiveRecord::Migration
  def change
    # Add a database-level uniqueness constraint for databases that support it
    # (postgres & sqlite)
    if connection.adapter_name =~ /postgres|sqlite/i
      add_index 'spree_stock_items', ['variant_id', 'stock_location_id'], where: 'deleted_at is null', unique: true
    end
  end
end

class AddStockItemUniqueIndex < ActiveRecord::Migration
  def change
    # Add a database-level uniqueness constraint for databases that support it
    # (postgres and sqlite > 3.8)
    if connection.supports_partial_index?
      add_index 'spree_stock_items', ['variant_id', 'stock_location_id'], where: 'deleted_at is null', unique: true
    end
  end
end

Use supports_partial_index instead of adapter_name
Use supports_partial_index instead of adapter_name

This allows tests to run under sqlite versions below 3.8
