I have an InstallSchema.php that does not create the table in the database. Here is the code of the schema php:
<?php
namespace MyVendor\News\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 news table
$tableName = $installer->getTable('simplenews');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
// Create news 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'
)
->addColumn(
'summary',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Summary'
)
->addColumn(
'description',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Description'
)
->addColumn(
'created_at',
Table::TYPE_DATETIME,
null,
['nullable' => false],
'Created At'
)
->addColumn(
'status',
Table::TYPE_SMALLINT,
null,
['nullable' => false, 'default' => '0'],
'Status'
)
->setComment('News Table')
->setOption('type', 'InnoDB')
->setOption('charset', 'utf8');
$installer->getConnection()->createTable($table);
}
$installer->endSetup();
}
}
I know I'm not the first one to have this issue, so I tried everything I could find about this. Here is what I have done to try make it works.
Before every try, executing sql
Delete from setup_module where module like '%module_name%';
I have of course checked that the query worked properly.
I have tried to install it with UpgradeSchema.php and change the version of the module in
magento/app/code/MyVendor/module/etc/module.xml (from 1.0.0 to 1.0.1),
it didn't work.
I have also tried to install it with Recurring.php
I'm using the command
sudo php bin/magento setup:upgrade
to install the table in the database. This command display no error and i can see my module in the output of the command.
I have also tried
setup:di:compile
to see any errors, but can't find any errors.
I had no problem installing magento, everything looks good so I'm lost.
EDIT : My module is active (I checked it with sudo php bin/magento module:status)