|
2 | 2 |
|
3 | 3 | namespace Jh\Import\Setup;
|
4 | 4 |
|
| 5 | +use Magento\Framework\DB\Adapter\AdapterInterface; |
5 | 6 | use Magento\Framework\DB\Ddl\Table;
|
6 | 7 | use Magento\Framework\Setup\ModuleContextInterface;
|
7 | 8 | use Magento\Framework\Setup\SchemaSetupInterface;
|
8 | 9 | use Magento\Framework\Setup\UpgradeSchemaInterface;
|
9 | 10 |
|
| 11 | +use function array_key_exists; |
| 12 | + |
10 | 13 | /**
|
11 | 14 | * @author Aydin Hassan <[email protected]>
|
12 | 15 | */
|
@@ -305,6 +308,39 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
|
305 | 308 | $setup->getConnection()->createTable($csvArchiveTable);
|
306 | 309 | }
|
307 | 310 |
|
| 311 | + if (version_compare($context->getVersion(), '2.5.6', '<')) { |
| 312 | + $connection = $setup->getConnection(); |
| 313 | + $tableName = $setup->getTable('jh_import_history'); |
| 314 | + $fieldName = 'import_name'; |
| 315 | + $indexName = $setup->getIdxName($tableName, $fieldName, AdapterInterface::INDEX_TYPE_INDEX); |
| 316 | + |
| 317 | + $indexesList = $connection->getIndexList($tableName); |
| 318 | + |
| 319 | + if (!array_key_exists($indexName, $indexesList)) { |
| 320 | + $connection->addIndex( |
| 321 | + $tableName, |
| 322 | + $indexName, |
| 323 | + [$fieldName], |
| 324 | + AdapterInterface::INDEX_TYPE_INDEX |
| 325 | + ); |
| 326 | + } |
| 327 | + |
| 328 | + $tableName = $setup->getTable('jh_import_history_item_log'); |
| 329 | + $fieldName = 'id_value'; |
| 330 | + $indexName = $setup->getIdxName($tableName, $fieldName, AdapterInterface::INDEX_TYPE_INDEX); |
| 331 | + |
| 332 | + $indexesList = $connection->getIndexList($tableName); |
| 333 | + |
| 334 | + if (!array_key_exists($indexName, $indexesList)) { |
| 335 | + $connection->addIndex( |
| 336 | + $tableName, |
| 337 | + $indexName, |
| 338 | + [$fieldName], |
| 339 | + AdapterInterface::INDEX_TYPE_INDEX |
| 340 | + ); |
| 341 | + } |
| 342 | + } |
| 343 | + |
308 | 344 | $setup->endSetup();
|
309 | 345 | }
|
310 | 346 | }
|
0 commit comments