From 79d7f750f497591ae8f9f193ebe8675c08ee927c Mon Sep 17 00:00:00 2001 From: Stephan Schuler Date: Wed, 11 Nov 2020 10:56:58 +0100 Subject: [PATCH] FEATURE: Allow version numbers in full namespace 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. --- Classes/Domain/Service/VersionResolver.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Classes/Domain/Service/VersionResolver.php b/Classes/Domain/Service/VersionResolver.php index 0a5e2ab..74c2939 100644 --- a/Classes/Domain/Service/VersionResolver.php +++ b/Classes/Domain/Service/VersionResolver.php @@ -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(?\\d{14})(\\\\|$)#', $migrationClassName, $matches); + return $matches['dateFormatVersionNumber']; } }