I have created a lot of tables using InstallSchema.php and put some data by InstallData.php in my custom module.

Once i want create a new table, Can i do it with upgrade scripts so i'm not create it manually in phpmyadmin? If using install schema i had to remove my module in setup_module table, and it makes data is reinserted while doing setup upgrade.

1 Answer 1


Yes, we can create new table using UpgradeSchema.php. Inside public function upgrade() add below scripts:

if (version_compare($context->getVersion(), '2.0.0', '<=')) {
    $installer = $setup;

    $table = $installer->getConnection()
        ->addColumn(/* put some column attribute here */);


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.