Add check for duplicate migrations names when loading migrations
[MAILPOET-5416]
This commit is contained in:
committed by
Aschepikov
parent
ec8b5260dd
commit
725d81077f
@ -55,10 +55,15 @@ class Repository {
|
||||
* @return array<array{level: string, name: string}>
|
||||
*/
|
||||
public function loadAll(): array {
|
||||
return array_merge(
|
||||
$migrations = array_merge(
|
||||
$this->loadForLevel(self::MIGRATIONS_LEVEL_DB),
|
||||
$this->loadForLevel(self::MIGRATIONS_LEVEL_APP)
|
||||
);
|
||||
$duplicateNames = array_diff_assoc(array_column($migrations, 'name'), array_unique(array_column($migrations, 'name')));
|
||||
if (!empty($duplicateNames)) {
|
||||
throw MigratorException::duplicateMigrationNames($duplicateNames);
|
||||
}
|
||||
return $migrations;
|
||||
}
|
||||
|
||||
private function loadForLevel(string $level): array {
|
||||
|
Reference in New Issue
Block a user