Skip to content

Commit

Permalink
fix(migration-preview): display a message if no attributes set
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Aug 6, 2024
1 parent e227d5a commit 825be0a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/Command/Db/Migrations/PreviewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public function execute(InputInterface $input, OutputInterface $output): int {
}
$table->render();

$unsupportedApps = $this->metadataManager->getUnsupportedApps($metadata['migrations']);
if (!empty($unsupportedApps)) {
$output->writeln('');
$output->writeln('Those apps are not supporting metadata yet and might initiate migrations on upgrade: <info>' . implode(', ', $unsupportedApps) . '</info>');
}

return 0;
}

Expand Down Expand Up @@ -90,6 +96,9 @@ private function displayMigrations(Table $table, string $appId, array $data): vo
/** @var MigrationAttribute[] $attributes */
foreach($data as $migration => $attributes) {
$attributesStr = [];
if (empty($attributes)) {
$attributesStr[] = '<comment>(metadata not set)</comment>';
}
foreach($attributes as $attribute) {
$definition = '<info>' . $attribute->definition() . "</info>";
$definition .= empty($attribute->getDescription()) ? '' : "\n " . $attribute->getDescription();
Expand Down
12 changes: 12 additions & 0 deletions lib/private/Migration/MetadataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ public function getMigrationsAttributesFromReleaseMetadata(
];
}

/**
* returns list of installed apps that does not support migrations metadata (yet)
*
* @param array<array-key, array<array-key, array>> $metadata
*
* @return string[]
* @since 30.0.0
*/
public function getUnsupportedApps(array $metadata): array {
return array_values(array_diff($this->appManager->getInstalledApps(), array_keys($metadata['apps'])));
}

/**
* convert raw data to a list of MigrationAttribute
*
Expand Down

0 comments on commit 825be0a

Please sign in to comment.