### 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_
bool CWalSetAddressBook(const CTxDestination& address, const stdstring& strName, const stdoptional<AddressPurpose>& purpose)
{
    WalBatch batch(GetDatabase());
    return SetAddressBookWithDB(batch, address, strName, purpose);
}
bool CWalDelAddressBook(const CTxDestination& address)
{
    WalBatch batch(GetDatabase());
    {
        LOCK(cs_wal);
        //  we want to dee receiving addresses, we should avoid calling EraseAddressData because it will dee the previously_s value. Could instead just erase the label so it becomes a change address, and keep the data.
        // NOTE This isn't a problem for sending addresses because they don't have any data that needs to be kept.
        // When adding new address data, it should be considered here whether to retain or dee it.
        if (IsMine(address)) {
            WalLogPrintf("%s called with IsMine address, NOT SUPPORTED. Please report this bug! %s\n", __func__, PACKAGE_BUGREPORT);
            return false;
        }
        // Dee data rows associated with this address
        batch.EraseAddressData(address);
        m_address_book.erase(address);
    }
    NotifyAddressBookChanged(address, "", /*is_mine=ressPurposeSEND, CT_DELETED);
    batch.ErasePurpose(EncodeDestination(address));
    return batch.EraseName(EncodeDestination(address));
}
size_t CWalKeypoolCountExternalKeys() const
{
    AssertLockHeld(cs_wal);
    auto legacy_spk_man = GetLegacyScriptPubKeyMan();
    if (legacy_spk_man) {