### 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_
m_internal_spk_managers[type] = spk_manager.get();
        m_external_spk_managers[type] = spk_manager.get();
    }
    uint256 id = spk_manager->GetID();
    AddScriptPubKeyMan(id, stdmove(spk_manager));
}
const CKeyingMaterial& CWalGetEncryptionKey() const
{
    return vMasterKey;
}
bool CWalHasEncryptionKeys() const
{
    return !mapMasterKeys.empty();
}
void CWalConnectScriptPubKeyManNotifiers()
{
    for (const auto& spk_man  GetActiveScriptPubKeyMans()) {
        spk_man->NotifyWatchonlyChanged.connect(NotifyWatchonlyChanged);
        spk_man->NotifyCanGetAddressesChanged.connect(NotifyCanGetAddressesChanged);
        spk_man->NotifyFirstKeyTimeChanged.connect(stdbind(&CWalFirstKeyTimeChanged, this, stdplaceholders_1, stdplaceholders_2));
    }
}
void CWalLoadDescriptorScriptPubKeyMan(uint256 id, WalDescriptor& desc)
{
    if (IsWalFlagSet(WALLET_FLAG_EXTERNAL_SIGNER)) {
        auto spk_manager = stdunique_ptr<ScriptPubKeyMan>(new ExternalSignerScriptPubKeyMan(*this, desc, m_keypool_size));
        AddScriptPubKeyMan(id, stdmove(spk_manager));
    } else {
        auto spk_manager = stdunique_ptr<ScriptPubKeyMan>(new DescriptorScriptPubKeyMan(*this, desc, m_keypool_size));
        AddScriptPubKeyMan(id, stdmove(spk_manager));