8

For example i don't have setup scripts in My module,can i ignore setup_version tag in module.xml file.

In m1 automatically modules installed,now it's first throwing an error(if we don't run setup upgrade command). Why I need to manually run setup upgrade?

What is the scenario schema_version and data_version will be different? I observed almost records in setup_module table contain same values.

  • 1
    automated upgrade was removed in favor of performance and stability. Checking and comparing all modules version on each and every request is useless overhead in production. Upgrading database is the kind of action that should be under full control of developer, but not application itself. – V Korotun Jun 16 '16 at 8:05
  • In M2 there are two kind of database modifications you may have, by implementing two corresponding interfaces: "\Magento\Framework\Setup\UpgradeDataInterface" and "\Magento\Framework\Setup\UpgradeSchemaInterface". So, you can make upgrades to the database data without changing database schema. That's why versions of those live their own lives. – V Korotun Jun 16 '16 at 8:07
11

data_version is the version of data added via the data scripts.

Those scripts are developped under the module folder under the Setup/InstallData.php and Setup/UpgradeData.php

schema_version is the version of the database schema added via the setup scripts.

Those scripts are developed under the module folder under the Setup/InstallSchema.php and Setup/UpgradeSchema.php

So the scenario when data_version and schema_version are different is the following:

  • you have a module that have both setup and data scripts
  • normally you should run php bin/magento setup:upgrade so both schema and data scripts will run
  • instead of doing this you first run php bin/magento setup:db-schema:upgrade . At this point the schema_version will be different to the data_version
  • running php bin/magento setup:db-data:upgrade will upgrade the data and make both versions the same
  • 1
    But why will anyone run those commands individually instead of setup:upgrade – MagePsycho Jun 27 '16 at 7:42
  • 1
    @MagePsycho well yeah that's not a normal behavior. But as both commands are available it can happen right. – Raphael at Digital Pianism Jun 27 '16 at 8:04
  • @MagePsycho There is no reason, I think it is completely redundant. – Bunyamin Inan Nov 16 '17 at 18:41

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.