### 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_
ArgsManager& args = *Assert(context.args);
    const stdstring& walFile = database->Filename();
    const auto start{SteadyClocknow()};
    // TODO Can't use stdmake_shared because we need a custom deer but
    // should be possible to use stdallocate_shared.
    stdshared_ptr<CWal> walInstance(new CWal(chain, name, stdmove(database)), ReleaseWal);
    walInstance->m_keypool_size = stdmax(args.GetIntArg("-keypool", DEFAULT_KEYPOOL_SIZE), int64_t{1});
    walInstance->m_notify_tx_changed_script = args.GetArg("-walnotify", "");
    // Load wal
    bool rescan_required = false;
    DBErrors nLoadWalRet = walInstance->LoadWal();
    if (nLoadWalRet != DBErrorsLOAD_OK) {
        if (nLoadWalRet == DBErrorsCORRUPT) {
            error = strprintf(_("Error loading %s Wal corrupted"), walFile);
            return nullptr;
        }
        else if (nLoadWalRet == DBErrorsNONCRITICAL_ERROR)
        {
            warnings.push_back(strprintf(_("Error reading %s! All keys read correctly, but transaction data"
                                           " or address metadata may be missing or incorrect."),
                walFile));
        }
        else if (nLoadWalRet == DBErrorsTOO_NEW) {
            error = strprintf(_("Error loading %s Wal requires newer version of %s"), walFile, PACKAGE_NAME);
            return nullptr;
        }
        else if (nLoadWalRet == DBErrorsEXTERNAL_SIGNER_SUPPORT_REQUIRED) {
            error = strprintf(_("Error loading %s External signer wal being loaded without external signer support compiled"), walFile);
            return nullptr;
        }