php - Silverstripe FulltextSearchable converts the table Engines to MyIsam -


for adding sitesearch functionality, when enable fulltextsearchable in silverstripe, converts page tables myisam default, need keep tables innodb only. using mysql version > 5.6(so, support fulltext)

as you've pointed out innodb support fulltext search since version mysql version 5.6, mysqlschemamanager comes framework prevents using innodb tables fulltext indexes defined. perhaps can raise issue on github. can create own schemamanager without restriction (by extending mysqlschemamanager , overriding altertable()):

# compare https://github.com/silverstripe/silverstripe-framework/blob/3.5/model/connect/mysqlschemamanager.php#l100 class mycustomschemamanager extends mysqlschemamanager {      public function altertable($tablename, $newfields = null, $newindexes = null, $alteredfields = null,                                $alteredindexes = null, $alteredoptions = null, $advancedoptions = null     ) {         if ($this->isview($tablename)) {             $this->alterationmessage(                 sprintf("table %s not changed view", $tablename),                 "changed"             );             return;         }         $alterlist = array();          if ($newfields) {             foreach ($newfields $k => $v) {                 $alterlist[] .= "add \"$k\" $v";             }         }         if ($newindexes) {             foreach ($newindexes $k => $v) {                 $alterlist[] .= "add " . $this->getindexsqldefinition($k, $v);             }         }         if ($alteredfields) {             foreach ($alteredfields $k => $v) {                 $alterlist[] .= "change \"$k\" \"$k\" $v";             }         }         if ($alteredindexes) {             foreach ($alteredindexes $k => $v) {                 $alterlist[] .= "drop index \"$k\"";                 $alterlist[] .= "add " . $this->getindexsqldefinition($k, $v);             }         }          $dbid = self::id;         if ($alteredoptions && isset($alteredoptions[$dbid])) {             $this->query(sprintf("alter table \"%s\" %s", $tablename, $alteredoptions[$dbid]));             $this->alterationmessage(                 sprintf("table %s options changed: %s", $tablename, $alteredoptions[$dbid]),                 "changed"             );         }          $alterations = implode(",\n", $alterlist);         $this->query("alter table \"$tablename\" $alterations");     }  } 

then can use injector use custom class:

# config.yml injector:   mysqlschemamanager:     class: mycustomschemamanager 

you should able use static create_table_options force innodb engine, , create fulltext indexes through indexes static.

example:

# somepage.php      /**  * force innodb database engine.  *  * @var array  */ private static $create_table_options = [     'mysqldatabase' => 'engine=innodb' ];  /**   * define fulltext indexes create.  *  * @var array  */ private static $indexes = [     'searchfields' => [         'type' => 'fulltext',         'name' => 'searchfields',         'value' => '"myfield", "tags"',     ] ]; 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -