Try to move objects from one realm to another

We’ve been use realm swift on our iOS app for awhile. Suppose we have Person And Student in realm, now we want to move All Person to reamlB.
We could do that:

        let results = Person.allObjects(in: realm) as! RLMResults<Person>
        
        do {
            for object in results {
                realmB.beginWriteTransaction()
                Person.create(in: realmB, withValue: object)
                try realmB.commitWriteTransaction()

                realm.beginWriteTransaction()
                realm.delete(object as! RLMObject)
                try realm.commitWriteTransaction()
            }

        }catch {
            print(error)
        }
        

But where should we put the code, since the app start, it might use Person very sooner, should it query from realm or realmB?
So we think, can we do that on realm migration? since the migration not done, the code would block, the app would keep go on.

        config.migrationBlock = {(migration, oldVersion) in
            if oldVersion < 4 {
                migration.enumerateObjects(Person.className()) { oldObject, newObject in
                    if  let realmB = RealmB.shared.client()  {
                        realmB.beginWriteTransaction()
                        Person.create(in: realmB, withValue: oldObject)
                        do {
                            try realmB.commitWriteTransaction()
                        }catch {
                            print(error)
                        }
                    }

saddy, we can’t. the realmB could not be get, it seems the app is being blocked. please help.