Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 70 lines (60 sloc) 2.649 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
<?php

/**
* This file is part of the PropelBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/

namespace Propel\PropelBundle\Command;

use Propel\PropelBundle\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output;

/**
* MigrationMigrateCommand.
*
* @author William DURAND <william.durand1@gmail.com>
*/
class MigrationMigrateCommand extends AbstractCommand
{
    /**
* @see Command
*/
    protected function configure()
    {
        $this
            ->setDescription('Executes the next migrations up')
            ->setDefinition(array(
                new InputOption('--up', '', InputOption::VALUE_NONE, 'Executes the next migration up'),
                new InputOption('--down', '', InputOption::VALUE_NONE, 'Executes the next migration down'),
            ))
            ->setHelp(<<<EOT
The <info>propel:migration:migrate</info> command checks the version of the database structure, looks for migrations files not yet executed (i.e. with a greater version timestamp), and executes them.

    <info>php app/console propel:migration:migrate [--up] [--down]</info>

    <info>php app/console propel:migration:migrate</info> : is the default command, it <comment>executes all</comment> migrations files.

    <info>php app/console propel:migration:migrate --up</info> : checks the version of the database structure, looks for migrations files not yet executed (i.e. with a greater version timestamp), and <comment>executes the first one</comment> of them.

    <info>php app/console propel:migration:migrate --down</info> : checks the version of the database structure, and looks for migration files already executed (i.e. with a lower version timestamp). <comment>The last executed migration found is reversed.</comment>
EOT
            )
            ->setName('propel:migration:migrate')
        ;
    }

    /**
* @see Command
*
* @throws \InvalidArgumentException When the target directory does not exist
*/
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        if ($input->getOption('down')) {
            $this->callPhing('migration-down');
        } elseif ($input->getOption('up')) {
            $this->callPhing('migration-up');
        } else {
            $this->callPhing('migrate');
        }

        $this->writeSummary($output, 'propel-migration');
    }
}
Something went wrong with that request. Please try again.