Fix migration and bug