$target = NULL; FileLock::setDirectory($GLOBALS['TMP_PATH']); $lock = new FileLock('web-migrate'); if ($lock->isLocked() && Request::int('release_lock')) { $lock->release(); } if (Request::int('target')) { $target = (int) Request::int('target'); } $version = new DBSchemaVersion('studip'); $migrator = new Migrator($path, $version, $verbose); if (Request::submitted('start')) { ob_start(); set_time_limit(0); $lock->lock(array('timestamp' => time(), 'user_id' => $GLOBALS['user']->id)); $migrator->migrate_to($target); $lock->release(); $announcements = ob_get_clean(); $message = MessageBox::Success(_("Die Datenbank wurde erfolgreich migriert."), explode("\n", $announcements)); } $current = $version->get(); $migrations = $migrator->relevant_migrations($target); $template = $template_factory->open('web_migrate'); $template->set_attribute('current_page', _('Datenbank-Migration')); $template->set_attribute('current', $current); $template->set_attribute('target', $target); $template->set_attribute('migrations', $migrations); $template->set_attribute('lock', $lock); $template->set_attribute('message', $message); echo $template->render(); include 'lib/include/html_end.inc.php';
/** * migrate plugin to top migration * * @param integer $plugin_id * @return string output from migrator */ public function migratePlugin($plugin_id) { $plugin_manager = PluginManager::getInstance(); $plugin = $plugin_manager->getPluginInfoById($plugin_id); $basepath = get_config('PLUGINS_PATH'); $plugindir = $basepath . '/' . $plugin['path'] . '/'; if (is_dir($plugindir . '/migrations')) { $schema_version = new DBSchemaVersion($plugin['name']); $migrator = new Migrator($plugindir . '/migrations', $schema_version, true); ob_start(); $migrator->migrate_to(null); $log = ob_get_clean(); } return $log; }