We are currently running stores which are 1000+ and hence clearing/regenerating is a big challenge. For that we are using cron to generate/clear cache but also we want to remove custom sections of code which do the same like setup:upgrade.
So currently I am trying to remove cache clearing code lines and override Magento\Setup\Console\Command\UpgradeCommand
I would like to do the same for Setup:di:compile and setup:static-content:deploy.
I used the preference method but didn't get the results as magento loads the root setup folder in a different way compared to other magento modules.
Is there any better way to do this?
In this article, we will find out how to install and upgrade sql script for module in Magento 2. When you install or upgrade a module, you may need to change the database structure or add some new data for current table. To do this, Magento 2 provide you some classes which you can do all of them.
I haven't found a better way so far than to completely override the file.
To do so, you just need to set a custom "psr-4" autoload path in your project composer.json:
"Magento\\Setup\\Console\\Command\\": "app/code/Your/Module/Console/Command/"
Then copy the entire file into your custom module :
app/code/Your/Module/Console/Command/UpgradeCommand.php
After running "composer install", Composer will load your file instead of the original file.
I'm not really comfortable with this solution, but it works...