Skip to content

Commit

Permalink
FEATURE: Allow version numbers in full namespace
Browse files Browse the repository at this point in the history
Migration classes are usually named like "Version20200911105700" to be
both, naturally sorted and with little chance to conflict.

This patch allows for migration classes with arbitrary names but
living in namespaces that contain the version number part.

This patch does not change how migratins are detected within the file
system.
  • Loading branch information
stephanschuler committed Nov 11, 2020
1 parent 1274eb6 commit 79d7f75
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Classes/Domain/Service/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ class VersionResolver
{
public function extractVersion(string $migrationClassName): string
{
preg_match('#\\Version(\d+)$#', $migrationClassName, $matches);
return $matches[1];
/*
* date format version number:
* 4 digits year
* + 2 digits month
* + 2 digits day
* + 2 digits hour
* + 2 digits minute
* + 2 digits second
* = 14 digits
*/
preg_match('#\\\\Version(?<dateFormatVersionNumber>\\d{14})(\\\\|$)#', $migrationClassName, $matches);
return $matches['dateFormatVersionNumber'];
}
}

0 comments on commit 79d7f75

Please sign in to comment.