Beispiel #1
0
 private static function generateIndexes(Template $template, Table $table)
 {
     /** @var Index $index */
     $indexes = [];
     foreach ($table->getIndexes() as $index) {
         $c = "new Index(" . "\"" . $index->getName() . "\"," . "['" . implode('\', \'', $index->getColumns()) . "']";
         if ($index->isUnique() || $index->getType() !== null) {
             $c .= ", " . ($index->isUnique() ? "true" : "false");
         }
         if ($index->getType() !== null) {
             $c .= ", '" . $index->getType() . "'";
         }
         $c .= ")";
         $indexes[] = $c;
     }
     $template->set('indexes', implode(",\n" . self::LINE_PREFIX, $indexes));
 }
Beispiel #2
0
 public final function dropIndexes()
 {
     $current = Connection::getTableIndices($this->table->getName());
     $new = $this->table->getIndexes();
     $this->drop($current, $new, $this->table->getName(), 'INDEX');
 }