diff --git a/src/Illuminate/Database/Console/Migrations/TableGuesser.php b/src/Illuminate/Database/Console/Migrations/TableGuesser.php index 30bd53096e06..733f72406bcf 100644 --- a/src/Illuminate/Database/Console/Migrations/TableGuesser.php +++ b/src/Illuminate/Database/Console/Migrations/TableGuesser.php @@ -4,15 +4,7 @@ class TableGuesser { - const CREATE_PATTERNS = [ - '/^create_(\w+)_table$/', - '/^create_(\w+)$/', - ]; - - const CHANGE_PATTERNS = [ - '/.+_(to|from|in)_(\w+)_table$/', - '/.+_(to|from|in)_(\w+)$/', - ]; + const PATTERN = '/^(?create)_(?\w+?)(?:_table)?$|(?J)(?add|drop|change).+_(?:to|from|in)_(?J)(?
\w+?)(?:_table)?$/'; /** * Attempt to guess the table name and "creation" status of the given migration. @@ -22,16 +14,8 @@ class TableGuesser */ public static function guess($migration) { - foreach (self::CREATE_PATTERNS as $pattern) { - if (preg_match($pattern, $migration, $matches)) { - return [$matches[1], $create = true]; - } - } - - foreach (self::CHANGE_PATTERNS as $pattern) { - if (preg_match($pattern, $migration, $matches)) { - return [$matches[2], $create = false]; - } + if (preg_match(self::PATTERN, $migration, $matches)) { + return [$matches['table'], $matches['method'] === 'create']; } } }