5

After adding a new module to Magento2 I need to enable it using

bin/magento module:enable Module_Name

then, I need to run the install scripts from the module using

bin/magento setup:upgrade

While running this I see in the log these messages:

  1. Schema creation/updates
  2. Installing schema
  3. Schema post-updates
  4. Data install/update

1, 2 and 4 are clear. Actually 1 and 2 seam to be the same thing. Applying the schema delta. So it runs everything from Setup/InstallSchema.php (that needs to run)
4 installs data for the modules. So it runs everything from Setup/InstallData.php.

What does Schema post-updates mean, what it does and how can I use it?

1 Answer 1

10

The idea of post-updates is that module can trigger additional install AFTER other modules did their schema install/updates. In our module we would need to have Setup/Recurring::install() to enable it.

Let's say we are installing 3 modules at the same time, all 3 have install scripts, but only first one has post-update, execution will go as follows:

  1. Module1/Setup/InstallSchema
  2. Module2/Setup/InstallSchema
  3. Module3/Setup/InstallSchema
  4. Module1/Setup/Recurring

Only current example in Magento2 is Indexer/Setup/Recurring that, I think, checks if new indexer is registered with new module and writes its state into database.

One more thing, post-updates is triggered always, it will be executed on each setup:upgrade, even if update didn't happen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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