Development

/branches/1.3/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineGenerateMigrationsDiffTask.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineGenerateMigrationsDiffTask.class.php

Revision 28871, 2.1 kB (checked in by Jonathan.Wage, 4 years ago)

[1.3, 1.4] Fixing issue with migrations diff autoloading (fixes #7272)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  * (c) Jonathan H. Wage <jonwage@gmail.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php');
13
14 /**
15  * Generate migration classes by producing a diff between your old and new schema.
16  *
17  * @package    symfony
18  * @subpackage doctrine
19  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
20  * @author     Jonathan H. Wage <jonwage@gmail.com>
21  * @version    SVN: $Id$
22  */
23 class sfDoctrineGenerateMigrationsDiffTask extends sfDoctrineBaseTask
24 {
25   /**
26    * @see sfTask
27    */
28   protected function configure()
29   {
30     $this->addOptions(array(
31       new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true),
32       new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
33     ));
34
35     $this->aliases = array();
36     $this->namespace = 'doctrine';
37     $this->name = 'generate-migrations-diff';
38     $this->briefDescription = 'Generate migration classes by producing a diff between your old and new schema.';
39
40     $this->detailedDescription = <<<EOF
41 The [doctrine:generate-migrations-diff|INFO] task generates migration classes by
42 producing a diff between your old and new schema.
43
44   [./symfony doctrine:generate-migrations-diff|INFO]
45 EOF;
46   }
47
48   /**
49    * @see sfTask
50    */
51   protected function execute($arguments = array(), $options = array())
52   {
53     $databaseManager = new sfDatabaseManager($this->configuration);
54     $config = $this->getCliConfig();
55
56     $this->logSection('doctrine', 'generating migration diff');
57
58     if (!is_dir($config['migrations_path']))
59     {
60       $this->getFilesystem()->mkdirs($config['migrations_path']);
61     }
62
63     spl_autoload_register(array('Doctrine_Core', 'modelsAutoload'));
64
65     $this->callDoctrineCli('generate-migrations-diff', array(
66       'yaml_schema_path' => $this->prepareSchemaFile($config['yaml_schema_path']),
67     ));
68   }
69 }
70
Note: See TracBrowser for help on using the browser.