mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Fix #2244 unnecessary composite index on tags table @Elkha
This commit is contained in:
parent
f16da70c64
commit
6328005ace
2 changed files with 13 additions and 8 deletions
|
|
@ -2,6 +2,6 @@
|
|||
<column name="tag_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="module_srl" type="number" size="11" default="0" notnull="notnull" index="idx_module_srl" />
|
||||
<column name="document_srl" type="number" size="11" default="0" notnull="notnull" index="idx_document_srl" />
|
||||
<column name="tag" type="varchar" size="180" notnull="notnull" />
|
||||
<column name="tag" type="varchar" size="180" notnull="notnull" index="idx_tag" />
|
||||
<column name="regdate" type="date" index="idx_regdate" />
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ class Tag extends ModuleObject
|
|||
*/
|
||||
public function moduleInstall()
|
||||
{
|
||||
$oDB = DB::getInstance();
|
||||
$oDB->addIndex('tags', 'idx_tag', array('document_srl', 'tag'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -21,9 +20,10 @@ class Tag extends ModuleObject
|
|||
*/
|
||||
public function checkUpdate()
|
||||
{
|
||||
// tag in the index column of the table tag
|
||||
// Convert unnecessary composite index into a single-column index.
|
||||
$oDB = DB::getInstance();
|
||||
if (!$oDB->isIndexExists('tags', 'idx_tag'))
|
||||
$index = $oDB->getIndexInfo('tags', 'idx_tag');
|
||||
if (!$index || count($index->columns) > 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -35,11 +35,16 @@ class Tag extends ModuleObject
|
|||
*/
|
||||
public function moduleUpdate()
|
||||
{
|
||||
// tag in the index column of the table tag
|
||||
// Convert unnecessary composite index into a single-column index.
|
||||
$oDB = DB::getInstance();
|
||||
if (!$oDB->isIndexExists('tags', 'idx_tag'))
|
||||
$index = $oDB->getIndexInfo('tags', 'idx_tag');
|
||||
if (!$index || count($index->columns) > 1)
|
||||
{
|
||||
$oDB->addIndex('tags', 'idx_tag', array('document_srl', 'tag'));
|
||||
if ($index)
|
||||
{
|
||||
$oDB->dropIndex('tags', 'idx_tag');
|
||||
}
|
||||
$oDB->addIndex('tags', 'idx_tag', ['tag']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue