Skip to content

Instantly share code, notes, and snippets.

Created January 4, 2013 16:30
Show Gist options
  • Select an option

  • Save anonymous/4453887 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/4453887 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Jan 4, 2013.
    39 changes: 39 additions & 0 deletions currentMigrationVersionTask.class.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    <?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());
    }
    }