/** * @return DBTestCreator */ public function createDB() { /** * @see testRecursionObjects() and meta * for TestParentObject and TestChildObject **/ $this->schema->getTableByName('test_parent_object')->getColumnByName('root_id')->dropReference(); foreach ($this->pool->getPool() as $name => $db) { foreach ($this->schema->getTables() as $name => $table) { $db->queryRaw($table->toDialectString($db->getDialect())); } } return $this; }
/** * Creates a diff between two scemas * @param DBSchema $from * @param DBSchema $to * * @return DBDiff itself */ function make(DBSchema $from, DBSchema $to) { // Firstly, process tables // Then, for each table process columns, constraints, indexes $fromTables = $from->getTables(); $toTables = $to->getTables(); $this->compare(&$this->createTables, &$this->dropTables, $fromTables, $toTables); $sameTables = array_intersect_key(array_keys($fromTables), array_keys($toTables)); foreach ($sameTables as $name) { $fromTable = $from->getTable($name); $toTable = $to->getTable($name); $this->compare(&$this->createColumns, &$this->dropColumns, $fromTable->getColumns(), $toTable->getColumns()); $this->compare(&$this->createConstraints, &$this->dropConstraints, $fromTable->getConstraints(), $toTable->getConstraints()); $this->compare(&$this->createIndexes, &$this->dropIndexes, $fromTable->getIndexes(), $toTable->getIndexes()); } return $this; }