. */ /** * Doctrine_Migration_Process * * @author Jonathan H. Wage * @package Doctrine * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @category Object Relational Mapping * @link www.phpdoctrine.com * @since 1.0 * @version $Revision: 1080 $ */ 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']), true); } } 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)), true); } } 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']))), true); } } 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['oldColumnName'] => array('definition' => $options))), true); } } 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']); } } }