From 0a981cdc5257ef98a1a37163beef5fc6fe13bb5f Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 20 May 2010 12:16:50 -0600 Subject: [PATCH] Clean up a bit --- horde/bin/db_migrate | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/horde/bin/db_migrate b/horde/bin/db_migrate index 8bb631b31..1451e3d94 100755 --- a/horde/bin/db_migrate +++ b/horde/bin/db_migrate @@ -1,6 +1,10 @@ #!/usr/bin/env php 'none', 'cli' => true)); - -// Get a database connection -$db = $GLOBALS['injector']->getInstance('Horde_Db_Adapter_Base'); +Horde_Registry::appInit('horde', array( + 'authentication' => 'none', + 'cli' => true +)); // Parse command line arguments array_shift($_SERVER['argv']); @@ -21,10 +25,12 @@ $args = $_SERVER['argv']; if (empty($args[0])) { $cli->fatal("An application argument is required"); } + $app = $args[0]; if (!in_array($app, $GLOBALS['registry']->listApps(array('inactive', 'hidden', 'notoolbar', 'admin', 'active')))) { $cli->fatal("$app is not a configured Horde application"); } + $action = 'up'; if (!empty($args[1])) { switch ($args[1]) { @@ -36,13 +42,17 @@ if (!empty($args[1])) { default: $action = 'migrate'; $targetVersion = $args[1]; + break; } } // Run -$dir = $GLOBALS['registry']->get('fileroot', $app) . '/migration/'; +$dir = $registry->get('fileroot', $app) . '/migration/'; + +$db = $injector->getInstance('Horde_Db_Adapter_Base'); $logger = new Horde_Log_Logger(new Horde_Log_Handler_Stream(STDOUT)); $migrator = new Horde_Db_Migration_Migrator($db, $logger, array('migrationsPath' => $dir, 'schemaTableName' => $app . '_schema_info')); + try { switch ($action) { case 'up': -- 2.11.0