Changeset 10833
- Timestamp:
- Feb 23, 2009, 8:04:33 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE3/trunk/lib/task/openpneMigrateTask.class.php
r10830 r10833 18 18 require sfConfig::get('sf_data_dir').'/version.php'; 19 19 20 $this->addArguments(array(21 new sfCommandArgument('name', sfCommandArgument::OPTIONAL, 'The plugin name or "OpenPNE"', 'OpenPNE'),22 ));23 24 20 $this->addOptions(array( 21 new sfCommandOption('target', null, sfCommandOption::PARAMETER_OPTIONAL, 'The target of migration'), 25 22 new sfCommandOption('to-version', 'v', sfCommandOption::PARAMETER_OPTIONAL, 'To version'), 26 23 new sfCommandOption('to-revision', 'r', sfCommandOption::PARAMETER_OPTIONAL, 'To revision'), … … 44 41 } 45 42 43 if (!$options['target'] && ($options['to-version'] || $options['to-revision'])) 44 { 45 throw new sfCommandException("You can't specify the to-version option or the to-revision option without the target option"); 46 } 47 46 48 if (!$options['no-build-model']) 47 49 { … … 50 52 51 53 $databaseManager = new sfDatabaseManager($this->configuration); 52 $migration = new opMigration($this->dispatcher, $databaseManager, $arguments['name'], null, $options['to-version']); 53 $migration->migrate(); 54 55 if (!empty($options['target'])) 56 { 57 $targets = array($options['target']); 58 } 59 else 60 { 61 $targets = array_merge(array('OpenPNE'), $this->getEnabledOpenPNEPlugin()); 62 } 63 64 foreach ($targets as $target) 65 { 66 $migration = new opMigration($this->dispatcher, $databaseManager, $target, null, $options['to-version']); 67 68 try 69 { 70 $migration->migrate(); 71 } 72 catch (Doctrine_Migration_Exception $e) 73 { 74 if (0 !== strpos($e->getMessage(), 'Already at version #')) 75 { 76 throw $e; 77 } 78 } 79 80 $this->logSection('migrate', sprintf('%s is now at revision %d.', $target, $migration->getCurrentVersion())); 81 } 54 82 } 55 83 … … 65 93 $task->run(); 66 94 } 95 96 protected function getEnabledOpenPNEPlugin() 97 { 98 $list = $this->configuration->getPlugins(); 99 $result = array(); 100 101 foreach ($list as $value) 102 { 103 if (!strncmp($value, 'op', 2)) 104 { 105 $result[] = $value; 106 } 107 } 108 109 return $result; 110 } 67 111 }
Note: See TracChangeset
for help on using the changeset viewer.