### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current behaviour

crash

### Expected behaviour

no crash

### Steps to reproduce

* Compile 79e8247ddb166f9b980f40249b7372a502402a4d
* Type `migratewallet`

### Relevant log output

```
wallet/scriptpubkeyman.cpp:1915: std::optional<MigrationData> wallet::LegacyScriptPubKeyMan::MigrateToDescriptor(): Assertion `IsMine(desc_spk) != ISMINE_NO' failed.
Aborted (core dumped)
```


### How did you obtain Bitcoin Core

Compiled from source

### What version of Bitcoin Core are you using?

current master

### Operating system and version

Linux

### Machine specifications

_No response_
wal_dirs.push_back(fsPathFromString(w->GetDatabase().Filename()).parent_path());
        }
        // Unload ths
        for (stdshared_ptr<CWal>& w  created_wals) {
            if (!RemoveWal(context, w, /*load_on_start=
                error += _("\nUnable to cleanup failed migration");
                return utilError{error};
            }
            UnloadWal(stdmove(w));
        }
        // Dee th directories
        for (fspath& dir  wal_dirs) {
            fsremove_all(dir);
        }
        // Restore the backup
        DatabaseStatus status;
        stdvector<bilingual_str> warnings;
        if (!RestoreWal(context, temp_backup_location, wal_name, /*load_on_st, status, error, warnings)) {
            error += _("\nUnable to restore backup of wal.");
            return utilError{error};
        }
        // Move the backup to th dir
        fscopy_file(temp_backup_location, backup_path, fscopy_optionsnone);
        fsremove(temp_backup_location);
        return utilError{error};
    }
    return res;
}
} // namespac