Voglio inserire un nuovo campo per la tabella del database nella mia estensione personalizzata usando lo schema di aggiornamento seguendo questo post , ma ho ricevuto un errore che diceva:
[Zend_Db_Statement_Exception]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'Category Depth.l
ime_eleveniacategory' doesn't exist, query was: DESCRIBE `Category Depth`.`
lime_eleveniacategory`
ecco il mio codice:
namespace Test\TestAgain\Setup;
use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
class UpgradeSchema implements UpgradeSchemaInterface
{
/**
* {@inheritdoc}
*/
public function upgrade(
SchemaSetupInterface $setup,
ModuleContextInterface $context
) {
$setup->startSetup();
if (version_compare($context->getVersion(), "1.0.0", "<")) {
//Your upgrade script
}
if (version_compare($context->getVersion(), '1.0.1', '<')) {
$tableName = $setup->getTable('lime_eleveniacategory');
if ($setup->getConnection()->isTableExists($tableName) == true) {
$connection = $setup->getConnection();
$connection->addColumn(
$tableName,
'category_depth',
['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,'nullable' => false, 'afters' => 'category_name'],
'Category Depth'
);
}
}
$setup->endSetup();
}
}