fixed migration  query in case of empty filter.