public function initSchema() { $driver = $this->conn->getDriver(); // (re)create tables $tableNames = $this->schema->getTableNames(); $this->conn->disableForeignKeys(); foreach ($tableNames as $tableName) { $this->dropTable($driver, $tableName); $this->createTable($driver, $tableName); } $this->conn->enableForeignKeys(); // (re)create views $viewNames = $this->schema->getViewNames(); $platform = $driver->getPlatform(); foreach ($viewNames as $viewName) { $this->dropView($platform, $viewName); $this->createView($platform, $viewName); } }
/** * @param Schema $schema * @return array */ public function getNeededModels(Schema $schema) { $baseRecordClass = $schema->getRecordBaseClass(); $tableNames = array_merge($schema->getTableNames(), $schema->getViewNames()); foreach ($tableNames as $key => $tableName) { $recordClass = $schema->getRecordClass($tableName); if ($recordClass == $baseRecordClass) { unset($tableNames[$key]); } else { $tableNames[$key] = $recordClass; } } return $tableNames; }
public function testGetViewNames() { $expected = array('author_user_view'); $actual = $this->schema->getViewNames(); $this->assertEquals($expected, $actual); }