Migration query for rights.

fixes #431