From 57a9ba22ff1c4b72f765bca31e3258c1046cbc0d Mon Sep 17 00:00:00 2001 From: ArrayIterator Date: Mon, 11 Mar 2024 15:55:41 +0700 Subject: [PATCH] change --- src/Console/Command/DatabaseChecker.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Console/Command/DatabaseChecker.php b/src/Console/Command/DatabaseChecker.php index 337fbdb..c675191 100644 --- a/src/Console/Command/DatabaseChecker.php +++ b/src/Console/Command/DatabaseChecker.php @@ -2065,11 +2065,23 @@ private function compareSchemaFix(Schema $currentSchema, Schema $realSchema, Sch protected function getAlterSQL(SchemaDiff $diff, AbstractPlatform $platform): array { $sql = $platform->getAlterSchemaSQL($diff); + $createTable = []; + $dropTable = []; // we don't use event subscriber $constraint = []; $createOrAddIndex = []; $dropIndex = []; foreach ($sql as $key => $query) { + if (preg_match('~^\s*CREATE\s+(TABLE|VIEW)~i', $query)) { + $createTable[] = $query; + unset($sql[$key]); + continue; + } + if (preg_match('~^\s*DROP\s+(TABLE|VIEW)~i', $query)) { + $dropTable[] = $query; + unset($sql[$key]); + continue; + } if (preg_match('~^\s*(CREATE|ADD|RENAME).+INDEX~i', $query)) { $createOrAddIndex[] = $query; unset($sql[$key]); @@ -2086,6 +2098,13 @@ protected function getAlterSQL(SchemaDiff $diff, AbstractPlatform $platform): ar } } - return array_merge($sql, $dropIndex, $createOrAddIndex, $constraint); + return array_merge( + $dropTable, + $createTable, + $sql, + $dropIndex, + $createOrAddIndex, + $constraint + ); } }