1

I've created a custom module, and I see the row in the setup_module table. When I change my version and run magento setup:upgrade, the version number updates as well. However, the table I defined is not being created. I also see the new module enabled in app/etc/config.php

I tried installing a module written by Magento, but I still see the same behavior - row is in setup_module but table does not exist.

I tried deleting the row from setup_module table and rerun magento setup:upgrade to execute InstallSchema.php, but the database tables aren't created even though the row is created setup_module again.

I also tried incrementing the version number and try UpgradeSchema.php, but it doesn't execute even though row in setup_module is updated.

I introduced errors in both InstallSchema.php and UpgradeSchema.php, but magento setup:upgrade doesn't does not output the error messages.

I also tried recreating the installation, and ensuring the file permissions were correct (owned by magento:www-data). Any other ideas?

I'm using v2.0.7 CE provided by DigitalOcean.

<?php
namespace Test\Project\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\DB\Ddl\Table;

class InstallSchema implements InstallSchemaInterface
{
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;
        $installer->startSetup();

        // Get tables
        $tableName = $installer->getTable('test_module');

        // Create table
        $table = $installer->getConnection()
        ->newTable($tableName)
        ->addColumn(
            'id',
            Table::TYPE_INTEGER,
            null,
            [
            'identity' => true,
            'unsigned' => true,
            'nullable' => false,
            'primary' => true
            ],
            'ID'
        )
        ->addColumn(
            'title',
            Table::TYPE_TEXT,
            null,
            ['nullable' => false, 'default' => ''],
            'Title'
        )
        ->setOption('type', 'InnoDB')
        ->setOption('charset', 'utf8');

        $installer->getConnection()->createTable($table);
        $installer->endSetup();
    } // close function install()
}
  • the module is enabled? try run bin/magento module:status. If not run bin/magento module:enable:<module_name> – 95623 Sep 26 '16 at 13:59
  • @95623 yes, the module is enabled. I see it in setup_module table as well as etc/config.php with value of 1 – Chris Sep 27 '16 at 20:44
  • try to delete all tables created by the module and downgrade/remove the module version on 'setup_module' table and re run setup:upgrade – 95623 Sep 28 '16 at 14:36
  • @95623 the module doesn't create any database tables in the first place...so there is nothing to delete. That's the main problem. Even if I put errors in InstallSchema.php and UpgradeSchema.php, and run setup:upgrade, it doesn't output any errors. It's as if those files aren't being read. – Chris Sep 29 '16 at 22:25
1

I resolved this by disabling all the caches via the admin and re-installing the module.

1

I have tried the following thats works for me. please check.

delete from setup_module where  module ='module_name';
sudo bin/magento setup:upgrade
sudo bin/magento setup:di:compile
sudo bin/magento cache:clean

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.