. */ /** * Doctrine_Migration_Process * * @package Doctrine * @subpackage Migration * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.com * @since 1.0 * @version $Revision: 1080 $ * @author Jonathan H. Wage */ class Doctrine_Migration_Process { public function getConnection($tableName) { return Doctrine::getConnectionByTableName($tableName); } public function processCreatedTables($tables) { foreach ($tables as $table) { $conn = $this->getConnection($table['tableName']); $conn->export->createTable($table['tableName'], $table['fields'], $table['options']); } } public function processDroppedTables($tables) { foreach ($tables as $table) { $conn = $this->getConnection($table['tableName']); $conn->export->dropTable($table['tableName']); } } public function processRenamedTables($tables) { foreach ($tables as $table) { $conn = $this->getConnection($table['newTableName']); $conn->export->alterTable($table['oldTableName'], array('name' => $table['newTableName'])); } } public function processAddedColumns($columns) { foreach ($columns as $column) { $conn = $this->getConnection($column['tableName']); $options = array(); $options = $column['options']; $options['type'] = $column['type']; $conn->export->alterTable($column['tableName'], array('add' => array($column['columnName'] => $options))); } } public function processRenamedColumns($columns) { foreach ($columns as $column) { $conn = $this->getConnection($column['tableName']); $conn->export->alterTable($column['tableName'], array('rename' => array($column['oldColumnName'] => array('name' => $column['newColumnName'])))); } } public function processChangedColumns($columns) { foreach ($columns as $column) { $conn = $this->getConnection($column['tableName']); $options = array(); $options = $column['options']; $options['type'] = $column['type']; $conn->export->alterTable($column['tableName'], array('change' => array($column['columnName'] => array('definition' => $options)))); } } public function processRemovedColumns($columns) { foreach ($columns as $column) { $conn = $this->getConnection($column['tableName']); $conn->export->alterTable($column['tableName'], array('remove' => array($column['columnName'] => array()))); } } public function processAddedIndexes($indexes) { foreach ($indexes as $index) { $conn = $this->getConnection($index['tableName']); $conn->export->createIndex($index['tableName'], $index['indexName'], $index['definition']); } } public function processRemovedIndexes($indexes) { foreach ($indexes as $index) { $conn = $this->getConnection($index['tableName']); $conn->export->dropIndex($index['tableName'], $index['indexName']); } } public function processCreatedConstraints($constraints) { foreach ($constraints as $constraint) { $conn = $this->getConnection($constraint['tableName']); $conn->export->createConstraint($constraint['tableName'], $constraint['constraintName'], $constraint['definition']); } } public function processDroppedConstraints($constraints) { foreach ($constraints as $constraint) { $conn = $this->getConnection($constraint['tableName']); $conn->export->dropConstraint($constraint['tableName'], $constraint['constraintName'], $constraint['primary']); } } public function processCreatedFks($foreignKeys) { foreach ($foreignKeys as $fk) { $conn = $this->getConnection($fk['tableName']); $conn->export->createForeignKey($fk['tableName'], $fk['definition']); } } public function processDroppedFks($foreignKeys) { foreach ($foreignKeys as $fk) { $conn = $this->getConnection($fk['tableName']); $conn->export->dropForeignKey($fk['tableName'], $fk['fkName']); } } }