Changeset View
Changeset View
Standalone View
Standalone View
scripts/sql/manage_storage.php
| Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | array( | ||||
| 'default' => $default_namespace, | 'default' => $default_namespace, | ||||
| 'help' => pht( | 'help' => pht( | ||||
| "Use namespace __namespace__ instead of the configured ". | "Use namespace __namespace__ instead of the configured ". | ||||
| "default ('%s'). This is an advanced feature used by unit tests; ". | "default ('%s'). This is an advanced feature used by unit tests; ". | ||||
| "you should not normally use this flag.", | "you should not normally use this flag.", | ||||
| $default_namespace), | $default_namespace), | ||||
| ), | ), | ||||
| array( | array( | ||||
| 'name' => 'dryrun', | 'name' => 'dryrun', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'Do not actually change anything, just show what would be changed.'), | 'Do not actually change anything, just show what would be changed.'), | ||||
| ), | ), | ||||
| array( | array( | ||||
| 'name' => 'disable-utf8mb4', | 'name' => 'disable-utf8mb4', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'Disable utf8mb4, even if the database supports it. This is an '. | 'Disable %s, even if the database supports it. This is an '. | ||||
| 'advanced feature used for testing changes to Phabricator; you '. | 'advanced feature used for testing changes to Phabricator; you '. | ||||
| 'should not normally use this flag.'), | 'should not normally use this flag.', | ||||
| 'utf8mb4'), | |||||
| ), | ), | ||||
| )); | )); | ||||
| } catch (PhutilArgumentUsageException $ex) { | } catch (PhutilArgumentUsageException $ex) { | ||||
| $args->printUsageException($ex); | $args->printUsageException($ex); | ||||
| exit(77); | exit(77); | ||||
| } | } | ||||
| // First, test that the Phabricator configuration is set up correctly. After | // First, test that the Phabricator configuration is set up correctly. After | ||||
| // we know this works we'll test any administrative credentials specifically. | // we know this works we'll test any administrative credentials specifically. | ||||
| $test_api = new PhabricatorStorageManagementAPI(); | $test_api = id(new PhabricatorStorageManagementAPI()) | ||||
| $test_api->setUser($default_user); | ->setUser($default_user) | ||||
| $test_api->setHost($default_host); | ->setHost($default_host) | ||||
| $test_api->setPort($default_port); | ->setPort($default_port) | ||||
| $test_api->setPassword($conf->getPassword()); | ->setPassword($conf->getPassword()) | ||||
| $test_api->setNamespace($args->getArg('namespace')); | ->setNamespace($args->getArg('namespace')); | ||||
| try { | try { | ||||
| queryfx( | queryfx( | ||||
| $test_api->getConn(null), | $test_api->getConn(null), | ||||
| 'SELECT 1'); | 'SELECT 1'); | ||||
| } catch (AphrontQueryException $ex) { | } catch (AphrontQueryException $ex) { | ||||
| $message = phutil_console_format( | $message = phutil_console_format( | ||||
| "**%s**\n\n%s\n\n%s\n\n%s\n\n**%s**: %s\n", | "**%s**\n\n%s\n\n%s\n\n%s\n\n**%s**: %s\n", | ||||
| pht('MySQL Credentials Not Configured'), | pht('MySQL Credentials Not Configured'), | ||||
| pht( | pht( | ||||
| 'Unable to connect to MySQL using the configured credentials. '. | 'Unable to connect to MySQL using the configured credentials. '. | ||||
| 'You must configure standard credentials before you can upgrade '. | 'You must configure standard credentials before you can upgrade '. | ||||
| 'storage. Run these commands to set up credentials:'), | 'storage. Run these commands to set up credentials:'), | ||||
| " phabricator/ $ ./bin/config set mysql.host __host__\n". | " phabricator/ $ ./bin/config set mysql.host __host__\n". | ||||
| " phabricator/ $ ./bin/config set mysql.user __username__\n". | " phabricator/ $ ./bin/config set mysql.user __username__\n". | ||||
| " phabricator/ $ ./bin/config set mysql.pass __password__", | " phabricator/ $ ./bin/config set mysql.pass __password__", | ||||
| pht( | pht( | ||||
| 'These standard credentials are separate from any administrative '. | 'These standard credentials are separate from any administrative '. | ||||
| 'credentials provided to this command with __%s__ or '. | 'credentials provided to this command with __%s__ or '. | ||||
| '__%s__, and must be configured correctly before you can proceed.', | '__%s__, and must be configured correctly before you can proceed.', | ||||
| '--user', | '--user', | ||||
| '--password'), | '--password'), | ||||
| pht('Raw MySQL Error'), | pht('Raw MySQL Error'), | ||||
| $ex->getMessage()); | $ex->getMessage()); | ||||
| echo phutil_console_wrap($message); | echo phutil_console_wrap($message); | ||||
| exit(1); | exit(1); | ||||
| } | } | ||||
| if ($args->getArg('password') === null) { | if ($args->getArg('password') === null) { | ||||
| // This is already a PhutilOpaqueEnvelope. | // This is already a PhutilOpaqueEnvelope. | ||||
| $password = $conf->getPassword(); | $password = $conf->getPassword(); | ||||
| } else { | } else { | ||||
| // Put this in a PhutilOpaqueEnvelope. | // Put this in a PhutilOpaqueEnvelope. | ||||
| $password = new PhutilOpaqueEnvelope($args->getArg('password')); | $password = new PhutilOpaqueEnvelope($args->getArg('password')); | ||||
| PhabricatorEnv::overrideConfig('mysql.pass', $args->getArg('password')); | PhabricatorEnv::overrideConfig('mysql.pass', $args->getArg('password')); | ||||
| } | } | ||||
| $api = new PhabricatorStorageManagementAPI(); | $api = id(new PhabricatorStorageManagementAPI()) | ||||
| $api->setUser($args->getArg('user')); | ->setUser($args->getArg('user')) | ||||
| PhabricatorEnv::overrideConfig('mysql.user', $args->getArg('user')); | ->setHost($default_host) | ||||
| $api->setHost($default_host); | ->setPort($default_port) | ||||
| $api->setPort($default_port); | ->setPassword($password) | ||||
| $api->setPassword($password); | ->setNamespace($args->getArg('namespace')) | ||||
| $api->setNamespace($args->getArg('namespace')); | ->setDisableUTF8MB4($args->getArg('disable-utf8mb4')); | ||||
| $api->setDisableUTF8MB4($args->getArg('disable-utf8mb4')); | PhabricatorEnv::overrideConfig('mysql.user', $api->getUser()); | ||||
| try { | try { | ||||
| queryfx( | queryfx( | ||||
| $api->getConn(null), | $api->getConn(null), | ||||
| 'SELECT 1'); | 'SELECT 1'); | ||||
| } catch (AphrontQueryException $ex) { | } catch (AphrontQueryException $ex) { | ||||
| $message = phutil_console_format( | $message = phutil_console_format( | ||||
| "**%s**\n\n%s\n\n**%s**: %s\n", | "**%s**\n\n%s\n\n**%s**: %s\n", | ||||
| pht('Bad Administrative Credentials'), | pht('Bad Administrative Credentials'), | ||||
| pht( | pht( | ||||
| 'Unable to connect to MySQL using the administrative credentials '. | 'Unable to connect to MySQL using the administrative credentials '. | ||||
| 'provided with the __%s__ and __%s__ flags. Check that '. | 'provided with the __%s__ and __%s__ flags. Check that '. | ||||
| 'you have entered them correctly.', | 'you have entered them correctly.', | ||||
| '--user', | '--user', | ||||
| '--password'), | '--password'), | ||||
| pht('Raw MySQL Error'), | pht('Raw MySQL Error'), | ||||
| $ex->getMessage()); | $ex->getMessage()); | ||||
| echo phutil_console_wrap($message); | echo phutil_console_wrap($message); | ||||
| exit(1); | exit(1); | ||||
| } | } | ||||
| $workflows = id(new PhutilClassMapQuery()) | $workflows = id(new PhutilClassMapQuery()) | ||||
| ->setAncestorClass('PhabricatorStorageManagementWorkflow') | ->setAncestorClass('PhabricatorStorageManagementWorkflow') | ||||
| ->execute(); | ->execute(); | ||||
| $patches = PhabricatorSQLPatchList::buildAllPatches(); | $patches = PhabricatorSQLPatchList::buildAllPatches(); | ||||
| Show All 9 Lines | |||||