Allow subdirectories in migration file names (#4225)

Credit to @GinoPane. Fixes #4224.
This commit is contained in:
Siarhei Karavai 2019-03-31 17:46:33 +03:00 committed by Luke Towers
parent 956a234920
commit 2e0d2d3888
2 changed files with 17 additions and 1 deletions

View File

@ -530,7 +530,7 @@ class VersionManager
protected function extractScriptsAndComments($details)
{
if (is_array($details)) {
$fileNamePattern = '/^[a-z_\-0-9\.]*\.php$/i';
$fileNamePattern = "/^[a-z0-9\_\-\.\/\\\]+\.php$/i";
$comments = array_values(array_filter($details, function ($detail) use ($fileNamePattern) {
return !preg_match($fileNamePattern, $detail);

View File

@ -186,6 +186,22 @@ class VersionManagerTest extends TestCase
'file.name.with.dots.php',
'1.0.2.scripts_can_go_anywhere.php'
]
],
[
[
'subdirectory/file.name.with.dots.php',
'The first update comment',
'subdirectory\1.0.2.scripts_can_go_anywhere.php',
'The second update comment',
],
[
'The first update comment',
'The second update comment'
],
[
'subdirectory/file.name.with.dots.php',
'subdirectory\1.0.2.scripts_can_go_anywhere.php'
]
]
];
}