-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from WeareJH/feature/adding-some-indexes-to-op…
…timise-table-search Adding some indexes for common conditions used for searching
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
*/ | ||
|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?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="Jh_Import" setup_version="1.8.0"/> | ||
<module name="Jh_Import" setup_version="2.5.6"/> | ||
</config> |