I have using all your code and try to create table and module...
1. Please add setup_version in module.xml file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_Module" setup_version="0.0.1">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
2. Please add these two line in your InstallSchema.php code..
$installer = $setup;
$installer->startSetup();
<?php
namespace Test\Module\Setup;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Setup\Exception;
class InstallSchema implements InstallSchemaInterface
{
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;
$installer->startSetup();
try {
$table = $setup->getConnection()
->newTable($setup->getTable('test_custom_table'))
->addColumn(
'test_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
'Test ID'
)
->addColumn(
'test_content',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['nullable' => false, 'default' => ''],
'Test Content'
)->setComment("Test Custom table");
$setup->getConnection()->createTable($table);
} catch(Exception $err) {
\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info($err->getMessage());
}
}
}
Once the extension is created, then we are creating installSchema.php file after executing the extension. Therefore, we have deleted the module form setup_module table and again run the command ....
php bin/magento setup:upgrade
php bin/magetno setup:static-content:deploy -f
php bin/magento cache:flush