Commit ffef34e766b922cf9341b81d64160423539fd123
1 parent
3a3121f3
KTS-2541
"indexes must be applied to searchable fields when recreating indexes" Updated. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7447 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
22 additions
and
5 deletions
bin/recreateIndexes.php
| ... | ... | @@ -77,6 +77,7 @@ class IndexRecreator |
| 77 | 77 | var $primary; |
| 78 | 78 | var $globalstart; |
| 79 | 79 | var $start; |
| 80 | + var $tables; | |
| 80 | 81 | |
| 81 | 82 | function microtimeFloat() |
| 82 | 83 | { |
| ... | ... | @@ -257,7 +258,11 @@ class IndexRecreator |
| 257 | 258 | $this->addForeignKey('metadata_lookup_tree','document_field_id', 'document_fields','id'); |
| 258 | 259 | // $this->addForeignKey('metadata_lookup_tree','metadata_lookup_tree_parent', '??','id'); |
| 259 | 260 | |
| 260 | - $this->addForeignKey('mime_types','mime_document_id','mime_documents','id'); | |
| 261 | + $this->addForeignKey('mime_types','mime_document_id','mime_documents','id', 'set null', 'set null'); | |
| 262 | + $this->addForeignKey('mime_types','extractor_id','mime_extractors','id', 'set null', 'set null'); | |
| 263 | + | |
| 264 | + $this->addForeignKey('mime_document_mapping','mime_type_id','mime_types','id'); | |
| 265 | + $this->addForeignKey('mime_document_mapping','mime_document_id','mime_documents','id'); | |
| 261 | 266 | |
| 262 | 267 | $this->addForeignKey('news','image_mime_type_id','mime_types','id'); |
| 263 | 268 | |
| ... | ... | @@ -398,6 +403,13 @@ class IndexRecreator |
| 398 | 403 | //$this->addIndex('document_types_lookup','disabled'); ? used |
| 399 | 404 | |
| 400 | 405 | $this->addIndex('documents','created'); |
| 406 | + $this->addIndex('documents','modified'); | |
| 407 | + $this->addIndex('documents','full_path','','(255)'); | |
| 408 | + $this->addIndex('documents','immutable'); | |
| 409 | + $this->addIndex('documents','checkedout'); | |
| 410 | + | |
| 411 | + $this->addIndex('document_content_version','filename','','(255)'); | |
| 412 | + $this->addIndex('document_content_version','size'); | |
| 401 | 413 | |
| 402 | 414 | $this->addIndex('field_behaviour_options',array('behaviour_id','field_id')); |
| 403 | 415 | |
| ... | ... | @@ -516,20 +528,22 @@ class IndexRecreator |
| 516 | 528 | $this->_exec($sql); |
| 517 | 529 | } |
| 518 | 530 | |
| 519 | - function addIndex($table, $fields, $type='') | |
| 531 | + function addIndex($table, $fields, $type='', $extra='') | |
| 520 | 532 | { |
| 533 | + if (!in_array($table, $this->tables)) return; | |
| 534 | + | |
| 521 | 535 | if (!is_array($fields)) $fields = array($fields); |
| 522 | 536 | $index = implode('_', $fields); |
| 523 | 537 | //$index = str_replace('_id','',$index); |
| 524 | 538 | $fields = implode(',',$fields); |
| 525 | - $sql = "alter table $table add $type index $index ($fields) "; | |
| 539 | + $sql = "alter table $table add $type index $index ($fields$extra) "; | |
| 526 | 540 | $this->_exec($sql); |
| 527 | 541 | } |
| 528 | 542 | |
| 529 | 543 | function addForeignKey($table, $field, $othertable, $otherfield, $ondelete='cascade', $onupdate='cascade') |
| 530 | 544 | { |
| 531 | - if (!in_array($table, $this->tables)) continue; | |
| 532 | - if (!in_array($othertable, $this->tables)) continue; | |
| 545 | + if (!in_array($table, $this->tables)) return; | |
| 546 | + if (!in_array($othertable, $this->tables)) return; | |
| 533 | 547 | |
| 534 | 548 | $sql = "alter table $table add foreign key ($field) references $othertable ($otherfield) "; |
| 535 | 549 | if ($ondelete != '') |
| ... | ... | @@ -594,6 +608,8 @@ class IndexRecreator |
| 594 | 608 | $this->addPrimaryKey('metadata_lookup','id'); |
| 595 | 609 | $this->addPrimaryKey('metadata_lookup_tree','id'); |
| 596 | 610 | $this->addPrimaryKey('mime_documents','id'); |
| 611 | + $this->addPrimaryKey('mime_extractors','id'); | |
| 612 | + $this->addPrimaryKey('mime_extractors',array('mime_type_id','mime_document_id')); | |
| 597 | 613 | $this->addPrimaryKey('mime_types','id'); |
| 598 | 614 | $this->addPrimaryKey('news','id'); |
| 599 | 615 | $this->addPrimaryKey('notifications','id'); |
| ... | ... | @@ -646,6 +662,7 @@ class IndexRecreator |
| 646 | 662 | |
| 647 | 663 | function addPrimaryKey($table, $primarykey) |
| 648 | 664 | { |
| 665 | + if (!in_array($table, $this->tables)) return; | |
| 649 | 666 | if (is_array($primarykey)) |
| 650 | 667 | { |
| 651 | 668 | $primarykey = implode(',', $primarykey); | ... | ... |