Fix migration queries