diff --git a/resources/sql/patches/059.engines.php b/resources/sql/patches/059.engines.php new file mode 100644 index 0000000000..765d89263b --- /dev/null +++ b/resources/sql/patches/059.engines.php @@ -0,0 +1,47 @@ + + AND s.TABLE_NAME != 'search_documentfield' + AND s.ENGINE != 'InnoDB'", + 'phabricator_'); + +if (!$tables) { + return; +} + +echo "There are ".count($tables)." tables using the MyISAM engine. These will ". + "now be converted to InnoDB. This process may take a few minutes, please ". + "be patient.\n"; + +foreach ($tables as $table) { + $name = $table['db'].'.'.$table['tbl']; + echo "Converting {$name}...\n"; + queryfx( + $conn, + "ALTER TABLE %T.%T ENGINE=InnoDB", + $table['db'], + $table['tbl']); +} +echo "Done!\n"; diff --git a/scripts/sql/upgrade_schema.php b/scripts/sql/upgrade_schema.php index 10d0159885..04bc25efab 100755 --- a/scripts/sql/upgrade_schema.php +++ b/scripts/sql/upgrade_schema.php @@ -1,196 +1,201 @@ #!/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; $conf = DatabaseConfigurationProvider::getConfiguration(); if ($options['u']) { $conn_user = $options['u']; $conn_pass = $options['p']; } else { $conn_user = $conf->getUser(); $conn_pass = $conf->getPassword(); } $conn_host = $conf->getHost(); // Split out port information, since the command-line client requires a // separate flag for the port. $uri = new PhutilURI('mysql://'.$conn_host); if ($uri->getPort()) { $conn_port = $uri->getPort(); $conn_bare_hostname = $uri->getDomain(); } else { $conn_port = null; $conn_bare_hostname = $conn_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); } diff --git a/src/infrastructure/setup/sql/PhabricatorSQLPatchList.php b/src/infrastructure/setup/sql/PhabricatorSQLPatchList.php index a4fda01f5b..5487267040 100644 --- a/src/infrastructure/setup/sql/PhabricatorSQLPatchList.php +++ b/src/infrastructure/setup/sql/PhabricatorSQLPatchList.php @@ -1,57 +1,55 @@ withSuffix('sql'); + $finder = new FileFinder($patches_dir); $results = $finder->find(); $patches = array(); foreach ($results as $path) { $matches = array(); - if (preg_match('/(\d+)\..*\.sql$/', $path, $matches)) { - $patches[] = array( - 'version' => (int)$matches[1], - 'path' => $patches_dir.$path, - ); - } else { - throw new Exception("Patch file '{$path}' is not properly named."); + if (!preg_match('/(\d+)\..*\.(sql|php)$/', $path, $matches)) { + continue; } + $patches[] = array( + 'version' => (int)$matches[1], + 'path' => $patches_dir.$path, + ); } // Files are in some 'random' order returned by the operating system // We need to apply them in proper order $patches = isort($patches, 'version'); return $patches; } public static function getExpectedSchemaVersion() { $patches = self::getPatchList(); $versions = ipull($patches, 'version'); $max_version = max($versions); return $max_version; } }