getMigrator() 공개 메소드

Returns a migrator for a module.
public getMigrator ( string $app, Horde_Log_Logger $logger = null ) : Horde_Db_Migration_Migrator
$app string An application or library name.
$logger Horde_Log_Logger A logger instance.
리턴 Horde_Db_Migration_Migrator A migrator for the specified module.
예제 #1
0
파일: Bundle.php 프로젝트: raz0rsdge/horde
 /**
  * Creates or updates the database tables.
  *
  * @throws Horde_Db_Exception
  */
 public function migrateDb()
 {
     $this->_cli->writeln();
     echo 'Creating and updating database tables...';
     $migration = new Horde_Core_Db_Migration(null, $this->_pearconf);
     // Try twice to work around unresolved migration dependencies.
     for ($i = 0; $i < 2; $i++) {
         $error = null;
         foreach ($migration->apps as $app) {
             $migrator = $migration->getMigrator($app);
             if ($migrator->getTargetVersion() <= $migrator->getCurrentVersion()) {
                 continue;
             }
             try {
                 $migrator->up();
             } catch (Exception $error) {
                 if ($i) {
                     throw $error;
                 }
             }
         }
         if (!$error) {
             break;
         }
     }
     $this->_cli->writeln($this->_cli->green(' done.'));
 }
예제 #2
0
 /**
  * Perform all functions for this task.
  */
 public function execute()
 {
     /* Check if test script is active. */
     if (empty($GLOBALS['conf']['testdisable'])) {
         $GLOBALS['notification']->push(_("The test script is currently enabled. For security reasons, disable test scripts when you are done testing (see horde/docs/INSTALL)."), 'horde.warning');
     }
     if (!empty($GLOBALS['conf']['sql']['phptype'])) {
         /* Check for outdated DB schemas. */
         $migration = new Horde_Core_Db_Migration();
         foreach ($migration->apps as $app) {
             $migrator = $migration->getMigrator($app);
             if ($migrator->getTargetVersion() > $migrator->getCurrentVersion()) {
                 $GLOBALS['notification']->push(Horde::link(Horde::url('admin/config/index.php', false, array('app' => 'horde'))) . _("At least one database schema is outdated.") . '</a>', 'horde.warning', array('content.raw', 'sticky'));
                 break;
             }
         }
     }
 }
예제 #3
0
파일: index.php 프로젝트: DSNS-LAB/Dmail
        $form->setSubmitted(true);
        if ($form->validate($vars)) {
            $config = new Horde_Config($app);
            if (!$config->writePHPConfig($vars)) {
                $notification->push(sprintf(_("Could not save the configuration file %s. Use one of the options below to save the code."), Horde_Util::realPath($config->configFile())), 'horde.warning', array('content.raw', 'sticky'));
            }
        } else {
            $notification->push(sprintf(_("The configuration for %s cannot be updated automatically. Please update the configuration manually."), $app), 'horde.error');
        }
    }
}
/* Update schema if requested. */
if ($vars->action == 'schema') {
    $apps = isset($vars->app) ? array($vars->app) : $migration->apps;
    foreach ($apps as $app) {
        $migrator = $migration->getMigrator($app);
        if ($migrator->getTargetVersion() <= $migrator->getCurrentVersion()) {
            continue;
        }
        try {
            $migrator->up();
            $notification->push(sprintf(_("Updated schema for %s."), $app), 'horde.success');
        } catch (Exception $e) {
            $notification->push($e);
        }
    }
}
/* Create NoSQL indices if requested. */
if ($vars->action == 'nosql_indices') {
    $nosql->buildIndices($vars->app);
}