diff --git a/src/Setup/UpgradeSchema.php b/src/Setup/UpgradeSchema.php index daa0f78..b304281 100644 --- a/src/Setup/UpgradeSchema.php +++ b/src/Setup/UpgradeSchema.php @@ -2,11 +2,14 @@ namespace Jh\Import\Setup; +use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Ddl\Table; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; use Magento\Framework\Setup\UpgradeSchemaInterface; +use function array_key_exists; + /** * @author Aydin Hassan */ @@ -305,6 +308,39 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con $setup->getConnection()->createTable($csvArchiveTable); } + if (version_compare($context->getVersion(), '2.5.6', '<')) { + $connection = $setup->getConnection(); + $tableName = $setup->getTable('jh_import_history'); + $fieldName = 'import_name'; + $indexName = $setup->getIdxName($tableName, $fieldName, AdapterInterface::INDEX_TYPE_INDEX); + + $indexesList = $connection->getIndexList($tableName); + + if (!array_key_exists($indexName, $indexesList)) { + $connection->addIndex( + $tableName, + $indexName, + [$fieldName], + AdapterInterface::INDEX_TYPE_INDEX + ); + } + + $tableName = $setup->getTable('jh_import_history_item_log'); + $fieldName = 'id_value'; + $indexName = $setup->getIdxName($tableName, $fieldName, AdapterInterface::INDEX_TYPE_INDEX); + + $indexesList = $connection->getIndexList($tableName); + + if (!array_key_exists($indexName, $indexesList)) { + $connection->addIndex( + $tableName, + $indexName, + [$fieldName], + AdapterInterface::INDEX_TYPE_INDEX + ); + } + } + $setup->endSetup(); } } diff --git a/src/etc/module.xml b/src/etc/module.xml index 5442a96..05b16c4 100644 --- a/src/etc/module.xml +++ b/src/etc/module.xml @@ -1,4 +1,4 @@ - +