add option detach to migrate function