Fix Nextcloud missing database indexes

 

Nextcloud security warning database indexes missing

Nextcloud adminsitration page shows the following waring:

The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running "occ db:add-missing-indices" those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster. Missing optional index "mail_messages_msgid_idx" in table "mail_messages". Missing optional index "fs_storage_path_prefix" in table "filecache".

Solution

Login to your Nextcloud system and use the command "sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices" to fix it.
 
root@nextcloud:~#
root@nextcloud:~# sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices
Adding additional mail_messages_msgid_idx index to the oc_mail_messages table, this can take some time...
oc_mail_messages table updated successfully.
Adding additional fs_storage_path_prefix index to the oc_filecache table, this can take some time...
oc_filecache table updated successfully.
root@nextcloud:~#


Nextcloud v31 on Ubuntu 22.04 - update php v8.1 to v8.4

If you are running HanssonIT Nextcloud VM with Ubuntu 22.04 and your Nextcloud has version 31 and you want to update to version 32, you are ...