7

I'm following the guide from Magento DevDocs about the Declarative Schema

I created a new module with old setup way (InstallSchema.php, InstallData.php) to test the convert install/upgrade schema scripts to db_schema.xml config. I ran two commands:

bin/magento setup:install --convert-old-scripts=1
bin/magento setup:upgrade --convert-old-scripts=1

But, I didn't see the db_schema.xml in my custom module. Why the db_schema.xml didn't generate in my module?

I also see the note from Magento

The Schema Listener tool listens for schema changes and attempts to change Magento code, so it should not be run in production mode. It is disabled by default.

So, what should I do in my case? My app is in developer mode.

2 Answers 2

11

After writing my question. I found my issue: I had run the setup upgrade command before.

So, I removed my module from setup_module table and my custom data table. Then I ran the two commands again.

bin/magento setup:install --convert-old-scripts=1
bin/magento setup:upgrade --convert-old-scripts=1
4
  • which commands?
    – Mohit Rane
    Commented Aug 8, 2019 at 10:17
  • php bin/magento setup:upgrade. It's our "common" command. But, before that, we need to remove module from setup_module. @MohitRane Commented Aug 8, 2019 at 10:44
  • okay, Thanks for the reply.
    – Mohit Rane
    Commented Aug 8, 2019 at 10:51
  • 2
    Didn't work for me. I removed from setup_module and also deleted the table second time. Didn't work at all. :( Commented Sep 1, 2020 at 7:44
2

Please follow the following steps to successfully Migrate yours install/upgrade scripts to declarative schema

  1. Go to your database search for setup_module table and delete all the modules for which you want to have db_schema.xml

  2. Now Paste your module/s in the Vendor directory app\code\vendor\module

  3. Then Give Permissions Required

  4. Finally Convert your schema by pasting the following command

    bin/magento setup:install --convert-old-scripts=1

  5. For further details please refer the link Migrate install/upgrade scripts to declarative schema

1
  • sudo chmod -R 777 dear readers, please don't do this.
    – Ejaz
    Commented Feb 28 at 9:46

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.