/** * Return Current Migration Status of the database. * * @return MigrationStatus */ public function getCurrentStatus() { $schemaManager = $this->connection->getSchemaManager(); $tables = $schemaManager->listTableNames(); if (!in_array('changelog', $tables)) { $table = new \Doctrine\DBAL\Schema\Table('changelog'); $table->addColumn('change_number', 'integer'); $table->addColumn('complete_dt', 'datetime', array('columnDefinition' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')); $table->addColumn('applied_by', 'string', array('length' => 100)); $table->addcolumn('description', 'string', array('length' => 500)); $table->setPrimaryKey(array('change_number')); $schemaManager->createTable($table); } $allMigrations = $this->getAllMigrations($this->schemaDirectory); $appliedMigrations = $this->getAppliedMigrations(); $applyMigrations = array(); foreach ($allMigrations as $revision => $data) { if (!isset($appliedMigrations[$revision])) { $applyMigrations[$revision] = $data; } } return new MigrationStatus($allMigrations, $appliedMigrations, $applyMigrations); }