#!/usr/bin/env php setTagline('manage Phabricator storage and schemata'); $args->setSynopsis(<<parseStandardArguments(); $conf = PhabricatorEnv::newObjectFromConfig('mysql.configuration-provider'); $default_user = $conf->getUser(); $default_password = $conf->getPassword(); $default_host = $conf->getHost(); $default_namespace = 'phabricator'; try { $args->parsePartial( array( array( 'name' => 'force', 'short' => 'f', 'help' => 'Do not prompt before performing dangerous operations.', ), array( 'name' => 'user', 'short' => 'u', 'param' => 'username', 'default' => $default_user, 'help' => "Connect with __username__ instead of the configured ". "default ('{$default_user}').", ), array( 'name' => 'password', 'short' => 'p', 'param' => 'password', 'default' => $default_password, 'help' => 'Use __password__ instead of the configured default.', ), array( 'name' => 'namespace', 'param' => 'name', 'default' => $default_namespace, 'help' => "Use namespace __namespace__ instead of the configured ". "default ('{$default_namespace}'). This is an advanced ". "feature used by unit tests; you should not normally ". "use this flag.", ), array( 'name' => 'dryrun', 'help' => 'Do not actually change anything, just show what would be '. 'changed.', ), )); } catch (PhutilArgumentUsageException $ex) { $args->printUsageException($ex); exit(77); } $api = new PhabricatorStorageManagementAPI(); $api->setUser($args->getArg('user')); $api->setHost($default_host); $api->setPassword($args->getArg('password')); $api->setNamespace($args->getArg('namespace')); try { queryfx( $api->getConn('meta_data', $select_database = false), 'SELECT 1'); } catch (AphrontQueryException $ex) { echo phutil_console_format( "**%s**: %s\n", 'Unable To Connect', $ex->getMessage()); exit(1); } $workflows = array( new PhabricatorStorageManagementDatabasesWorkflow(), new PhabricatorStorageManagementDestroyWorkflow(), new PhabricatorStorageManagementDumpWorkflow(), new PhabricatorStorageManagementStatusWorkflow(), new PhabricatorStorageManagementUpgradeWorkflow(), ); $patches = PhabricatorSQLPatchList::buildAllPatches(); foreach ($workflows as $workflow) { $workflow->setAPI($api); $workflow->setPatches($patches); } $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);