Occ db:add-missing-indices automatically after upgrade

dear all,

is there a way known on how to automate to run the occ db:add-missing-indices command?

after every upgrade I have to do that manually and that sucks

Sucks is kind of a strong term. If you’re already familiar with it, it only takes a minute per major version.

I think it isn’t automated because it could take some time on a large database.

executing is even less than a minute but remembering it, googling the cmd/ path to run it is just unsatisfying.

in case there is somewhere a cfg file to just say yes to do it with every upgrade, i would likte to take that.

my DB is not big, it is just a private cloud and eventhou it runs for 12 hrs, i dont care.

just want to get rid of doing this manually.

I don’t think that’s an option. Your system is going to take a certain amount of admin maintenance. All in all, this is quite simple and quick.

I set a bash alias so I can just type occ <arguments>

And the warning tells you exactly what to do along with a link… no Googling really needed.

1 Like

Hi,
I think it depends on what kind of automatism you want to build yourself :slightly_smiling_face:
The command (occ db:add-missing-indices) does not cause any issues if you run it without being requested in the admin overview section.
So if the manual steps annoy you, you could setup a cronjob to run the command every night.
While the missing indices also don’t hurt, it is no problem to wait for the next night after an update.

Other options:
You could write a script and set up a cronjob to run that script every x hours or also once every night. That script could check if a specific file in your user directory exists and contains a specific value.

Let me give an example:
After updating NC on your server, when the overview complains about missing indices, you create (or open the existing file) ‘add-indices.txt’ in the web GUI of NC for example in the folder ‘admin-stuff’ and enter the text ‘yes’ (via plaintext app). Now the next time the cronjob triggers the script, it checks if that file exists and if it contains the string ‘yes’ and if so, executes the occ command. Afterwards it removes the string ‘yes’ from the text file.

Important: don’t let the script delete the file! Only delete the content!

That way you can control the execution of the command from the web GUI without the need to login via ssh.

I wonder if there are some special apps, which can trigger scripts on specific events, like tagging a file or so, by the workflow app/ mechanism.

I have a folder with such tasks that I rarely do, where I just keep the commands (update something, resize partitions, …). So I’d keep just a file with the command line updater procedure, where you can add the missing-indeces.
I wouldn’t bother to automize something that takes that little time for 3 times a year. After running the upgrade, it’s also good to have a look around if there other things to do…