1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 10:42:41 +01:00

Allow bin/storage renamespace to work with underscores

If the namespace is something like "test_example" we currently fail to
renamespace the dump.

(Cowboy committing this since this is currently blocking a data export.)

Test Plan:

  - Renamespaced a local dump, examined the output, saw 60 create / 60 use, reimported it.
  - Will export in production.

Auditors: chad
This commit is contained in:
epriestley 2016-09-06 06:58:35 -07:00
parent 74d5ae7bec
commit 7e365fd3f1

View file

@ -138,9 +138,11 @@ final class PhabricatorStorageManagementRenamespaceWorkflow
$output_name));
}
$name_pattern = preg_quote($from, '@');
$patterns = array(
'use' => '@^(USE `)([^_]+)(_.*)$@',
'create' => '@^(CREATE DATABASE /\*.*?\*/ `)([^_]+)(_.*)$@',
'use' => '@^(USE `)('.$name_pattern.')(_.*)$@',
'create' => '@^(CREATE DATABASE /\*.*?\*/ `)('.$name_pattern.')(_.*)$@',
);
$found = array_fill_keys(array_keys($patterns), 0);
@ -151,16 +153,6 @@ final class PhabricatorStorageManagementRenamespaceWorkflow
foreach ($patterns as $key => $pattern) {
if (preg_match($pattern, $line, $matches)) {
$namespace = $matches[2];
if ($namespace != $from) {
throw new Exception(
pht(
'Expected namespace "%s", found "%s": %s.',
$from,
$namespace,
$line));
}
$line = $matches[1].$to.$matches[3];
$found[$key]++;
}