]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(migration-preview): display a message if no attributes set 47069/head
authorMaxence Lange <maxence@artificial-owl.com>
Tue, 6 Aug 2024 23:22:38 +0000 (22:22 -0100)
committerMaxence Lange <maxence@artificial-owl.com>
Tue, 6 Aug 2024 23:23:12 +0000 (22:23 -0100)
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
core/Command/Db/Migrations/PreviewCommand.php
lib/private/Migration/MetadataManager.php

index e35100dacb2e607d108d2d4c7c23dd3e2e4b7558..5a0e766ee6d18aaeeb53f65eb30135d54412fb23 100644 (file)
@@ -62,6 +62,12 @@ class PreviewCommand extends Command {
                }
                $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;
        }
 
@@ -90,6 +96,9 @@ class PreviewCommand extends Command {
                /** @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();
index 402252d6a4608793573b04a47b4ad00798660272..324c169c626f649bbfe0afcf871bd69fb15fa38e 100644 (file)
@@ -88,6 +88,18 @@ class MetadataManager {
                ];
        }
 
+       /**
+        * 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
         *