3

According to this dev doc (emphasis mine)

InstallData and InstallSchema scripts, which are executed on a clean (empty) database

UpgradeData and UpgradeSchema incremental scripts, which supplement an existing Magento database

Recurring scripts, which are executed each time you install or upgrade Magento

Does anyone know what feature this development document is talking about? As far as I recall, M2 only had InstallData, InstallSchema, UpgradeData and UpgradeSchema classes.

3

Alan, first of all, I want to say thank you for your blog. I learned a lot of Magento thing using it. Thanks a lot.

About the Recurring.php:

These scripts are fired every time u run setup:upgrade cli command and the good example of how it can be used you can find in Magento\Indexer\Setup\Recurring class where Magento_Indexer module checks for newly defined indexers and adds them to indexer_state table.

3

I think in devdocs there is another place where this is explained.

Magento executes your module’s recurring schema event class after every schema installation or upgrade stage. This class makes final modifications to the database schema after it has been installed or updated.

And you can use as reccuring schema script:

class \VendorName\ModuleName\Setup\Recurring implements \Magento\Framework\Setup\InstallSchemaInterface
{
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        //Recurring schema event logic
    }
}

You can also create reccuring data script:

Magento executes your module’s recurring data event class after every data installation or upgrade stage. This class makes final modifications to the database store after data has been installed or updated.

Example:

class \VendorName\ModuleName\Setup\RecurringData implements \Magento\Framework\Setup\InstallDataInterface
{
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        // Recurring data event logic
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.