#!/usr/bin/env php null, // Upgrade from specific version 'u' => null, // Override MySQL User 'p' => null, // Override MySQL Pass ); foreach (array('h', 'f') as $key) { // By default, these keys are set to 'false' to indicate that the flag was // passed. if (array_key_exists($key, $options)) { $options[$key] = true; } } if (!empty($options['h']) || ($options['v'] && !is_numeric($options['v']))) { usage(); } if (empty($options['f'])) { echo phutil_console_wrap( "Before running this script, you should take down the Phabricator web ". "interface and stop any running Phabricator daemons."); if (!phutil_console_confirm('Are you ready to continue?')) { echo "Cancelled.\n"; exit(1); } } // Use always the version from the commandline if it is defined $next_version = isset($options['v']) ? (int)$options['v'] : null; if ($options['u']) { $conn_user = $options['u']; $conn_pass = $options['p']; } else { $conn_user = PhabricatorEnv::getEnvConfig('mysql.user'); $conn_pass = PhabricatorEnv::getEnvConfig('mysql.pass'); } $conn_host = PhabricatorEnv::getEnvConfig('mysql.host'); $conn = new AphrontMySQLDatabaseConnection( array( 'user' => $conn_user, 'pass' => $conn_pass, 'host' => $conn_host, 'database' => null, )); try { $create_sql = <<getMessage(). "\n\n"; exit(1); } function usage() { echo "usage: upgrade_schema.php [-v version] [-u user -p pass] [-f] [-h]". "\n\n". "Run 'upgrade_schema.php -u root -p hunter2' to override the configured ". "default user.\n". "Run 'upgrade_schema.php -v 12' to apply all patches starting from ". "version 12. It is very unlikely you need to do this.\n". "Use the -f flag to upgrade noninteractively, without prompting.\n". "Use the -h flag to show this help.\n"; exit(1); }