cancel
Showing results for 
Search instead for 
Did you mean: 

Tables not created but module is activated and updated

SOLVED

Tables not created but module is activated and updated

Hi all,

I started learning Magento 2 recently. I created my first module and I was able to have it installed and activated by the system with the command:

 

 

./magento setup:upgrade

Just now I added two new files:

 

1. InstallData.php

2. InstallSchema.php

 

 

When I go to my XML file and increase the version number from i.e. 1.0.0 to 2.0.0 and run the command setup:upgrade again, it will re-install the module (I deleted it from the database too, and it has been added again after running this command) as expected.

 

Unfortunately the new tables and data are not added to the database, nor have I been given an error of any kind.

 

Can anyone tell me what is wrong?

 

P.S. I am using PHP Storm and I cannot get the xml working properly. I ran the command:

 

./bin/magento dev:urn-catalog:generate .idea/misc.xml

but then I get the error:

 

There are no commands defined in the "dev:urn-catalog" namespace.

 

Hope someone can help me out with this too.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Tables not created but module is activated and updated

Hello @infodevbiz4c43 

 

You should use UpgradeData and UpgradeSchema after changing the module version, take help from this blog :

https://www.mageplaza.com/magento-2-module-development/magento-2-how-to-create-sql-setup-script.html

 

But Magento recommend to use Declarative Schema, please check once here :

https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/

 

Hope it helps !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

View solution in original post

1 REPLY 1

Re: Tables not created but module is activated and updated

Hello @infodevbiz4c43 

 

You should use UpgradeData and UpgradeSchema after changing the module version, take help from this blog :

https://www.mageplaza.com/magento-2-module-development/magento-2-how-to-create-sql-setup-script.html

 

But Magento recommend to use Declarative Schema, please check once here :

https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/

 

Hope it helps !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy