Skip to content

Commit

Permalink
change
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrayIterator committed Mar 11, 2024
1 parent b204589 commit 57a9ba2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/Console/Command/DatabaseChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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
);
}
}

0 comments on commit 57a9ba2

Please sign in to comment.