Example #1
0
 /**
  * Get statement needed to create table.
  *
  * @param AbstractTable $table
  * @return string
  */
 protected function createStatement(AbstractTable $table)
 {
     if (!$table instanceof TableSchema) {
         throw new SchemaException("MySQL commander can process only MySQL tables.");
     }
     return parent::createStatement($table) . " ENGINE {$table->getEngine()}";
 }
Example #2
0
 /**
  * Synchronise foreign keys.
  *
  * @return $this
  */
 protected function synchroniseForeigns()
 {
     foreach ($this->comparator->addedForeigns() as $foreign) {
         $this->logger()->debug("Adding foreign key [{statement}] into table {table}.", ['statement' => $foreign->sqlStatement(), 'table' => $this->getName(true)]);
         $this->commander->addForeign($this, $foreign);
     }
     foreach ($this->comparator->alteredForeigns() as $pair) {
         /**
          * @var AbstractReference $initial
          * @var AbstractReference $current
          */
         list($current, $initial) = $pair;
         $this->logger()->debug("Altering foreign key [{statement}] to [{new}] in {table}.", ['statement' => $initial->sqlStatement(), 'table' => $this->getName(true)]);
         $this->commander->alterForeign($this, $initial, $current);
     }
     return $this;
 }