I have written a small module and I've made Setup classes include InstallData, InstallSchema, UpgradeData, and UpgradeSchema and put them in Setup folder, For the first time I did run setup:upgrade command everything was ok.

A table created and some data inserted. But then I tried to edit UpgradeSchema.php and UpgradeData.php to change table schema and data, but nothing happened.

I also changed module.xml and increase setup_version to 0.0.3 or 0.0.4, but it didn't work!

I commented the "if (version_compare($context->getVersion(), '0.0.2', '<'))" condition, but nothing changed after setup:upgrade again!

Please help me what to do.

  • did you try to if (version_compare($context->getVersion(), '0.0.3', '<'))? – Jurij Jazdanov Sep 5 '17 at 9:24
  • In module.xml I have setup_version=0.0.3, in UpdateSchema I have if (version_compare($context->getVersion(), '0.0.3', '<')) and I commented all upgrade method in UpgradeData Class – M Taheri Sep 5 '17 at 10:00
  • in the UpgradeSchema change the if – Jurij Jazdanov Sep 5 '17 at 10:01
  • Ok I changed it but UpdateSchema does not work – M Taheri Sep 5 '17 at 10:02
  • try changing to 0.0.5 everywhere and run setup:upgrade. – Jurij Jazdanov Sep 5 '17 at 10:03

I changed module.xml setup_version to 0.0.5 in UpgradeSchema.php

I changed the if clause

if (version_compare($context->getVersion(), '0.0.5', '<'))

And in setup_module table schema_version in 0.0.1. should I change the table?

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.