SUCCESS!!!
Out of frustration, I gave up on the precision scalpel approach and went with the brute-force hammer approach instead.
I decided to manually rename the index in oc_mail_messages from “mail_messages_msgid_id” to “mail_messages_msgid_idx”:
ALTER TABLE oc_mail_messages RENAME INDEX mail_messages_msgid_id TO mail_messages_msgid_idx
… and re-run the “occ db:add-missing-indices -vvv” command again.
That gave partial success! All other indexes were added:
Adding additional mail_smime_certs_uid_email_idx index to the oc_mail_smime_certificates table, this can take some time...
Removing mail_smime_certs_uid_idx index from the oc_mail_smime_certificates table
oc_mail_smime_certificates table updated successfully.
Adding additional mail_trusted_senders_idx index to the oc_mail_trusted_senders table, this can take some time...
Removing mail_trusted_senders_type index from the oc_mail_trusted_senders table
oc_mail_trusted_senders table updated successfully.
Adding additional mail_coll_idx index to the oc_mail_coll_addresses table, this can take some time...
Removing mail_coll_addr_userid_index index from the oc_mail_coll_addresses table
Removing mail_coll_addr_email_index index from the oc_mail_coll_addresses table
oc_mail_coll_addresses table updated successfully.
But the NC Admin still showed that the mail_messages_msgid_idx index was still missing:
* The database is missing some indexes. ... Missing optional index "mail_messages_msgid_idx" in table "mail_messages".
So I renamed the index from mail_messages_msgid_idx back to mail_messages_msgid_id:
ALTER TABLE oc_mail_messages RENAME INDEX mail_messages_msgid_idx TO mail_messages_msgid_id
… and re-ran the “occ db:add-missing-indices -vvv” command again.
Adding additional mail_messages_msgid_idx index to the oc_mail_messages table, this can take some time...
oc_mail_messages table updated successfully.
SUCCESS!!! Kinda-sorta
The NC admin was STILL showing a missing index for mail_messages_mb_id_uid_uidx"
* The database is missing some indexes. ... Missing optional index "mail_messages_mb_id_uid_uidx" in table "mail_messages".
Running “occ db:add-missing-indices -vvv” did not add the index. Nothing was done.
So inspecting the DB showed that:
mail_messages_msgid_id
mail_messages_msgid_idx
and
mail_messages_mb_id_uid_uidx indexes did all exist.
But mail_messages_mb_id_uid_uid did not exist.
So I went through the same procedure of renaming it from mail_messages_mb_id_uid_uidx to mail_messages_mb_id_uid_uid and re-ran the “occ db:add-missing-indices -vvv” command:
ALTER TABLE oc_mail_messages RENAME INDEX mail_messages_mb_id_uid_uidx TO mail_messages_mb_id_uid_uid
Adding additional mail_messages_mb_id_uid_uidx index to the oc_mail_messages table, this can take some time...
Removing mail_messages_mb_id_uid index from the oc_mail_messages table
oc_mail_messages table updated successfully.
100% SUCCESS!!!
NC admin now shows all indexes added, zero issues, and no entries in the error log since these changes.
Mail is working properly, and I do not see any issues at this point.
I’m sure there’s a better way to handle this, but this worked for me, and I thought I’d share for those of you still encountering this problem and just want it resolved even if the solution isn’t elegant.