Fix migration and roles detection mechanism