/**
  * Builds the DDL SQL to modify a database
  * based on a DatabaseDiff instance
  *
  * @return string
  */
 public function getModifyDatabaseDDL(DatabaseDiff $databaseDiff)
 {
     $ret = '';
     foreach ($databaseDiff->getRemovedTables() as $table) {
         $ret .= $this->getDropTableDDL($table);
     }
     foreach ($databaseDiff->getRenamedTables() as $fromTableName => $toTableName) {
         $ret .= $this->getRenameTableDDL($fromTableName, $toTableName);
     }
     foreach ($databaseDiff->getModifiedTables() as $tableDiff) {
         $ret .= $this->getModifyTableDDL($tableDiff);
     }
     foreach ($databaseDiff->getAddedTables() as $table) {
         $ret .= $this->getAddTableDDL($table);
     }
     if ($ret) {
         $ret = $this->getBeginDDL() . $ret . $this->getEndDDL();
     }
     return $ret;
 }
Ejemplo n.º 2
0
 /**
  * Builds the DDL SQL to modify a database
  * based on a DatabaseDiff instance
  *
  * @return     string
  */
 public function getModifyDatabaseDDL(DatabaseDiff $databaseDiff)
 {
     $ret = $this->getBeginDDL();
     foreach ($databaseDiff->getRemovedTables() as $table) {
         $ret .= $this->getDropTableDDL($table);
     }
     foreach ($databaseDiff->getRenamedTables() as $fromTableName => $toTableName) {
         $ret .= $this->getRenameTableDDL($fromTableName, $toTableName);
     }
     foreach ($databaseDiff->getAddedTables() as $table) {
         $ret .= $this->getAddTableDDL($table);
         $ret .= $this->getAddIndicesDDL($table);
     }
     foreach ($databaseDiff->getModifiedTables() as $tableDiff) {
         $ret .= $this->getModifyTableDDL($tableDiff);
     }
     foreach ($databaseDiff->getAddedTables() as $table) {
         $ret .= $this->getAddForeignKeysDDL($table);
     }
     $ret .= $this->getEndDDL();
     return $ret;
 }