X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fschema.php;h=2e27955881c235450bbc383ad3e75791cfe11031;hb=9e9cbdf505e9ec66c7e9d60bfe170f8d41a146e2;hp=e4b7f416cd7fa7a4e474e9548e8831e876702e46;hpb=e7c7fd39fc948f1169512916077185dd29973b60;p=quix0rs-gnu-social.git diff --git a/lib/schema.php b/lib/schema.php index e4b7f416cd..2e27955881 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -168,17 +168,24 @@ class Schema } } - // Multi-value indexes are advisory and for best portability - // should be created as separate statements. + // Wrap the CREATE TABLE around the main body chunks... $statements = array(); $statements[] = $this->startCreateTable($name, $def) . "\n" . implode($sql, ",\n") . "\n" . $this->endCreateTable($name, $def); + + // Multi-value indexes are advisory and for best portability + // should be created as separate statements. if (!empty($def['indexes'])) { foreach ($def['indexes'] as $col => $colDef) { $this->appendCreateIndex($statements, $name, $col, $colDef); } } + if (!empty($def['fulltext indexes'])) { + foreach ($def['fulltext indexes'] as $col => $colDef) { + $this->appendCreateFulltextIndex($statements, $name, $col, $colDef); + } + } return $statements; } @@ -282,6 +289,20 @@ class Schema $statements[] = "CREATE INDEX $name ON $table " . $this->buildIndexList($def); } + /** + * Append an SQL statement with an index definition for a full-text search + * index over one or more columns on a table. + * + * @param array $statements + * @param string $table + * @param string $name + * @param array $def + */ + function appendCreateFulltextIndex(array &$statements, $table, $name, array $def) + { + throw new Exception("Fulltext index not supported in this database"); + } + /** * Append an SQL statement to drop an index from a table. * @@ -581,7 +602,7 @@ class Schema $this->appendAlterAddForeign($phrase, $keyName, $def['foreign keys'][$keyName]); } - $this->appendAlterExtras($phrase, $tableName); + $this->appendAlterExtras($phrase, $tableName, $def); if (count($phrase) > 0) { $sql = 'ALTER TABLE ' . $tableName . ' ' . implode(",\n", $phrase); @@ -702,7 +723,7 @@ class Schema $phrase[] = 'DROP FOREIGN KEY ' . $keyName; } - function appendAlterExtras(array &$phrase, $tableName) + function appendAlterExtras(array &$phrase, $tableName, array $def) { // no-op } @@ -945,7 +966,7 @@ class Schema */ function validateDef($tableName, array $def) { - if (count($def) && $def[0] instanceof ColumnDef) { + if (isset($def[0]) && $def[0] instanceof ColumnDef) { $def = $this->oldToNew($tableName, $def); }