Managing database changes when pinning plugins via Composer

I’m sure this has been asked before, but I haven’t found anything - neither on this discourse nor on other sites … Maybe I haven’t used the proper keywords?

When managing plugins via Composer, after an update how are database changes applied?

Is there a way to trigger the plugin’s update methods after the source has been updated via composer? I guess this doesn’t only apply to database changes, but all changes that happen on update.

Or am I completely overthinking this and plugins & themes manage this on their own and not via WP hooks?

AFAIK when a plugin needs to make database changes after an update, it will prompt you in the admin area until you allow the upgrade, regardless of how you installed it.

Based on my understanding, plugins check to see if they need to upgrade the database when they are run (i.e., when the admin area is accessed), not when they are “installed”—remember, there are many ways to install/upgrade plugins, not just the “Upgrade” link in the admin area. You could also just replace them via FTP or something, in which case there’s nothing happening in WordPress that tells it “a plugin is being installed.” It’s up to the plugin to determine that it previously existed on the site in an older capacity, and then run, or prompt to run, any necessary upgrades.

There may be some more involved plugins that have a non-standard install/upgrade process, but those are going to be so individually-specific that you’d have to address them as they came up.

1 Like

Thanks for the reply. It does make sense, I think I was mentally just going down a wrong point and didn’t find anything on this part in any topic concerning composer.

What I read is that WordPress itself will trigger a notice in the admin area to change the database (or force so when trying to access wp-admin). So there’s nothing in the way of pinning versions via composer - except of course customers who want the point and click experience…

I believe the database upgrade messages are generated by plugins through WordPress; they aren’t WordPress itself detecting a plugin database upgrade is necessary.

Bedrock also disable in-WordPress plugin updates (and autoupdates) to avoid your plugins getting out of sync (and stop customers who want the point-and-click experience):

Funny enough, seeing this activated in a project that was handed to us initially brought me to Bedrock/the Roots stack

This topic was automatically closed after 42 days. New replies are no longer allowed.