Created
January 4, 2013 16:30
-
-
Save anonymous/4453887 to your computer and use it in GitHub Desktop.
Symfony 1 task that displays the current migration version of the database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Displays the current migration version of the database | |
* | |
* @version 1.0 | |
* @author Ain Tohvri <[email protected]> | |
* @see sfBaseTask | |
*/ | |
class currentMigrationVersionTask extends sfBaseTask | |
{ | |
protected function configure() | |
{ | |
$this->addOptions(array( | |
new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'), | |
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), | |
new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), | |
)); | |
$this->namespace = 'doctrine'; | |
$this->name = 'current-migration-version'; | |
$this->briefDescription = 'Display current migration version'; | |
$this->detailedDescription = <<<EOF | |
The [current-migration-version|INFO] displays the version of the current migration. | |
Call it with: | |
[php symfony doctrine:current-migration-version|INFO] | |
EOF; | |
} | |
protected function execute($arguments = array(), $options = array()) | |
{ | |
$databaseManager = new sfDatabaseManager($this->configuration); | |
$connection = $databaseManager->getDatabase($options['connection'])->getConnection(); | |
$migration = new Doctrine_Migration(dirname(__FILE__)); | |
$this->logSection($this->name, $migration->getCurrentVersion()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment