Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116#!/usr/bin/env php<?php
$root = dirname(dirname(dirname(__FILE__)));require_once $root.'/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);$args->setTagline('manage Phabricator storage and schemata');$args->setSynopsis(<<<EOHELP**storage** __workflow__ [__options__]Manage Phabricator database storage and schema versioning.
**storage** upgradeInitialize or upgrade Phabricator storage.
**storage** upgrade --user __root__ --password __hunter2__Use administrative credentials for schema changes.EOHELP);$args->parseStandardArguments();
$conf = PhabricatorEnv::newObjectFromConfig( 'mysql.configuration-provider', array($dao = null, 'w'));
$default_user = $conf->getUser();$default_host = $conf->getHost();$default_port = $conf->getPort();$default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace();
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', '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);}
if ($args->getArg('password') === null) { // This is already a PhutilOpaqueEnvelope. $password = $conf->getPassword();} else { // Put this in a PhutilOpaqueEnvelope. $password = new PhutilOpaqueEnvelope($args->getArg('password')); PhabricatorEnv::overrideConfig('mysql.pass', $args->getArg('password'));}
$api = new PhabricatorStorageManagementAPI();$api->setUser($args->getArg('user'));PhabricatorEnv::overrideConfig('mysql.user', $args->getArg('user'));$api->setHost($default_host);$api->setPort($default_port);$api->setPassword($password);$api->setNamespace($args->getArg('namespace'));
try { queryfx( $api->getConn(null), 'SELECT 1');} catch (AphrontQueryException $ex) { echo phutil_console_format( "**%s**: %s\n", 'Unable To Connect', $ex->getMessage()); exit(1);}
$workflows = id(new PhutilSymbolLoader()) ->setAncestorClass('PhabricatorStorageManagementWorkflow') ->loadObjects();
$patches = PhabricatorSQLPatchList::buildAllPatches();
foreach ($workflows as $workflow) { $workflow->setAPI($api); $workflow->setPatches($patches);}
$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);