/** * 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.')); }
/** * 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; } } } }
} } try { $vfs->writeData($path, 'conf.php', $config); $notification->push(sprintf(_("Successfully wrote %s"), Horde_Util::realPath($path . '/conf.php')), 'horde.success'); $GLOBALS['session']->remove('horde', 'config/' . $app); } catch (Horde_Vfs_Exception $e) { $no_errors = false; $notification->push(sprintf(_("Could not write configuration for \"%s\": %s"), $app, $e->getMessage()), 'horde.error'); } } $registry->rebuild(); return $no_errors; } $hconfig = new Horde_Config(); $migration = new Horde_Core_Db_Migration(__DIR__ . '/../../..'); $nosql = new Horde_Core_Nosql(); $vars = $injector->getInstance('Horde_Variables'); $a = $registry->listAllApps(); /* Check for suspicious missing of migration data. */ if (!in_array('Horde_Core', $migration->apps)) { $notification->push(_("Database migration files not found. Please check PEAR's data_dir configuration setting."), 'horde.error'); } /* Check for versions if requested. */ $versions = array(); if ($vars->check_versions) { $pearConfig = PEAR_Config::singleton(); $packageFile = new PEAR_PackageFile($pearConfig); $packages = array(); foreach ($pearConfig->getRegistry()->packageInfo(null, null, 'pear.horde.org') as $package) { $packages[$package['name']] = $package['version']['release'];