On my own Magento 2 custom module, I want to install a custom database table. This is the InstallSchema class code:
<?php
namespace MyVendor\MyModule\Setup;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
class InstallSchema implements InstallSchemaInterface
{
/**
* @inheritdoc
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
$table = $setup->getConnection()
->newTable($setup->getTable('my_table'))
->addColumn(
'greeting_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
'Greeting ID'
)
->addColumn(
'message',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['nullable' => false, 'default' => ''],
'Message'
)->setComment("Greeting Message table");
$setup->getConnection()->createTable($table);
$setup->endSetup();
}
}
But the install method is not being executed.
Attached an xdebug session with breakpoints inside the function, never called.
Removed the module line in setup_module database table and re-run
bin/magento setup:upgradeSet the developer mode, disable cache, run a
setup:di:compile, still fails.
Any ideas? I've also tried to use UpdateSchema changing the module version, no luck.
I'm running Magento 2 on a Ubuntu Server virtual box. Permissions on folders are set correctly.
bin/magento module:enable MyVendor_MyModule- wesleywmd