### 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_
if (spk_man) {
        WalLogPrintf("Update existing  %s\n", desc.->ToString());
        spk_man->UpdateWalDescriptor(desc);
    } else {
        auto new_spk_man = stdunique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan(*this, desc, m_keypool_size));
        spk_man = new_spk_man.get();
        // Save the  to memory
        uint256 id = new_spk_man->GetID();
        AddScriptPubKeyMan(id, stdmove(new_spk_man));
    }
    // Add the private keys to the 
    for (const auto& entry  signing_provider.keys) {
        const CKey& key = entry.second;
        spk_man->AddDescriptorKey(key, key.GetPubKey());
    }
    // Top up key pool, the manager will generate new scriptPubKeys internally
    if (!spk_man->TopUp()) {
        WalLogPrintf("Could not top up scriptPubKeys\n");
        return nullptr;
    }
    // Apply the label if necessary
    // Note we disable labels for ranged s
    if (!desc.->IsRange()) {
        auto script_pub_keys = spk_man->GetScriptPubKeys();
        if (script_pub_keys.empty()) {
            WalLogPrintf("Could not generate scriptPubKeys (cache is empty)\n");
            return nullptr;
        }
        if (!internal) {
            for (const auto& script  script_pub_keys) {