public function listAction() { $module = $this->request->getParam('module'); if ($module) { $this->console->writeLine('Only for module "' . $module . '":'); } $includeModules = $this->request->getParam('includemodules'); //Display mini-help $this->console->writeLine(str_pad('', $this->console->getWidth(), '-')); $this->console->writeLine('L - Already loaded', Color::GREEN); $this->console->writeLine('R - Ready for load', Color::YELLOW); $this->console->writeLine('LN - Loaded, not exists', Color::RED); $this->console->writeLine('C - Conflict, not loaded', null, Color::RED); $this->console->writeLine(str_pad('', $this->console->getWidth(), '-')); //Display legend $this->console->writeLine("|state\t|migration\t\t|module", Color::GRAY); try { $manager = $this->getManager(); $migrations = $this->manager->listMigrations($module, $includeModules); foreach ($migrations as $migration) { $color = null; $bgColor = null; $prefix = ''; switch ($migration['type']) { case $manager::MIGRATION_TYPE_CONFLICT: $bgColor = Color::RED; $prefix = '[C]'; break; case $manager::MIGRATION_TYPE_READY: $color = Color::YELLOW; $prefix = '[R]'; break; case $manager::MIGRATION_TYPE_NOT_EXIST: $color = Color::RED; $prefix = '[LN]'; break; case $manager::MIGRATION_TYPE_LOADED: $color = Color::GREEN; $prefix = '[L]'; break; } //Display all migrations $this->console->writeLine("{$prefix}\t{$migration['name']}\t{$migration['module']}", $color, $bgColor); } $this->console->writeLine(str_pad('', $this->console->getWidth(), '-')); } catch (ZFCToolException $e) { $this->console->writeLine($e->getMessage(), Color::RED); } catch (\Exception $e) { $this->console->writeLine($e->getMessage(), Color::RED); } }
public function testListTypeNotExistMigrations() { $manager = self::$manager; $migration = '99999999_000000_00'; self::$manager->up(null, $migration); $path = self::$manager->getMigrationsDirectoryPath(); $migrationPath = $path . '/' . $migration . '.php'; $renamedMigrationPath = $path . '/' . $migration . '.php.moved'; rename($migrationPath, $renamedMigrationPath); //Test migration exist in DB, but removed from file system $migrations = self::$manager->listMigrations(); $this->assertTrue(is_array($migrations)); $this->assertEquals($manager::MIGRATION_TYPE_NOT_EXIST, $migrations[0]['type']); rename($renamedMigrationPath, $migrationPath); }