add query_migrate function