ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 10799


Ignore:
Timestamp:
Feb 19, 2009, 3:24:08 PM (13 years ago)
Author:
ebihara
Message:

#3502:added migrate script for initializing database

Location:
OpenPNE3/trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/lib/migration/opMigration.class.php

    r10737 r10799  
    1818class opMigration extends Doctrine_Migration
    1919{
    20   protected $targetName = '';
     20  protected
     21    $dispatcher = null,
     22    $dbManager = null,
     23    $targetName = '',
     24    $connectionName = '';
    2125
    2226 /**
     
    2731    $this->dispatcher = $dispatcher;
    2832    $this->dbManager = $dbManager;
    29     if (!$connectionName)
     33    $this->connectionName = $connectionName;
     34    if (!$this->connectionName)
    3035    {
    3136      $names = $this->dbManager->getNames();
    32       $connectionName = array_shift($names);
     37      $this->connectionName = array_shift($names);
    3338    }
    34     $this->database = $this->dbManager->getDatabase($connectionName);
     39    $this->database = $this->dbManager->getDatabase($this->connectionName);
    3540
    3641    $params = $this->database->getParameterHolder()->getAll();
     
    3944
    4045    $this->connection = $doctrine->getDoctrineConnection();
     46    $this->connection->getManager()->setAttribute(Doctrine::ATTR_IDXNAME_FORMAT, '%s');
    4147    $this->doctrineProcess = new opUpdateDoctrineMigrationProcess($this->connection);
    4248
    43     if ($pluginName)
     49    if ($pluginName && $pluginName !== 'OpenPNE')
    4450    {
    4551      $this->targetName = $pluginName;
     
    126132  * @see Doctrine_Migration
    127133  */
     134  protected function getMigrationClass($num)
     135  {
     136    foreach ($this->_migrationClasses as $classMigrationNum => $info)
     137    {
     138      $className = $info['className'];
     139
     140      if ($classMigrationNum == $num)
     141      {
     142        return new $className($this->dispatcher, $this->dbManager, $this->targetName, $this->connectionName);
     143      }
     144    }
     145
     146    throw new Doctrine_Migration_Exception('Could not find migration class for migration step: '.$num);
     147  }
     148
     149 /**
     150  * @see Doctrine_Migration
     151  */
    128152  public function loadMigrationClassesFromDirectory()
    129153  {
  • OpenPNE3/trunk/lib/task/openpneMigrateTask.class.php

    r10737 r10799  
    3939  protected function execute($arguments = array(), $options = array())
    4040  {
    41     $databaseManager = new sfDatabaseManager($this->configuration);
    42     $migration = new opMigration($this->dispatcher, $databaseManager);
    43     $migration->migrate();
    44 
    4541    if (!$options['no-build-model'])
    4642    {
    4743      $this->buildModel();
    4844    }
     45
     46    $databaseManager = new sfDatabaseManager($this->configuration);
     47    $migration = new opMigration($this->dispatcher, $databaseManager);
     48    $migration->migrate();
    4949  }
    5050
     
    5757    $task = new sfPropelBuildFiltersTask($this->dispatcher, $this->formatter);
    5858    $task->run();
     59    $task = new sfCacheClearTask($this->dispatcher, $this->formatter);
     60    $task->run();
    5961  }
    6062}
Note: See TracChangeset for help on using the changeset viewer.