I had created a sample module when I tried to create table I knew I have to delete the entry from my setup_module table or else the install schema wont run so.
DELETE from setup_module where module='Mastering_SampleModule'
After that I performed
sudo bin/magento setup:upgrade;
Everthing runs fine, the module is being created again in the setup_module table as I check from
select * from setup_module WHERE module= 'Mastering_SampleModule'
but the table is not being created .
on trying to introduce error in installschema class and then running sudo bin/magento setup:upgrade
the error is shown in the console according to error introduced and it is irrelevant. But table is not being created as expected if I run
sudo bin/magento setup:upgrade;
command without any errors.
<?php
namespace Mastering\SampleModule\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)
{
$setup->startSetup();
$table = $setup->getConnection()
->newTable($setup->getTable('mastering_sample_item)'))
->addColumn(
'id',
Table::TYPE_INTEGER,
null,
['identity'=>true,'nullable'=>false,'primary'=>true],
'Table Id'
)->addColumn(
'name',
Table::TYPE_TEXT,
255,
['nullable'=>false],
'Table Name'
)->addIndex(
$setup->getIdxName('mastering_sample_item',['name']),
['name']
)->setComment(
'Sample Items'
);
$setup->getConnection()->createTable($table);
$setup->endSetup();
}
}
I think there is any error in my install method , can someone tell me how to debug installschema and upgrade schema classes?