17.0.10 to 18.0.14 upgrade: oc_direct_edit exists

I am trying to upgrade a Nextcloud install from v17 to v18. When running upgrade, I get this error message:

Doctrine\DBAL\Exception\TableExistsException: An exception occurred while executing 'CREATE TABLE oc_direct_edit (id BIGINT AUTO_INCREMENT NOT NULL, editor_id VARCHAR(64) NOT NULL, token VARCHAR(64) NOT NULL, file_id BIGINT NOT NULL, user_id VARCHAR(64) DEFAULT NULL, share_id BIGINT DEFAULT NULL, timestamp BIGINT UNSIGNED NOT NULL, accessed TINYINT(1) DEFAULT '0' NOT NULL, INDEX IDX_4D5AFECA5F37A13B (token), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE utf8_bin ENGINE = InnoDB': SQLSTATE[42S01]: Base table or view already exists: 1050 Table '`nextcloud`.`oc_direct_edit`' already exists

This occurred when trying to upgrade an existing nextcloud directory.

I then tried renaming the existing nextcloud directory, downloading the latest v18 zip file, unpacking that and copying over the config file.

Same issue.

in /var/db/mysql/nextcloud, I see this file: oc_direct_edit.ibd

I tried deleting it manually but it somehow automatically gets re-created and then the update script fails again.

Can someone suggest a way forward here?

My nextcloud config is here: nextcloud config - Pastebin.com

Nextcloud version: 17.0.10.1
Operating system and version: FreeBSD 12.2-RELEASE-P3
Apache or nginx version: Apache 2.4.46
PHP version: 7.3.25