summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-04-12 17:47:40 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2018-05-30 21:28:05 +0200
commitb40629ac8caf5d488053a9ab2e89210bf14e1b4c (patch)
treee4a5c79218778a494250768832d55640939c65ec /lib/private
parent2dd49206c74eaa8e9149b117775f4747483ba5bd (diff)
downloadnextcloud-server-b40629ac8caf5d488053a9ab2e89210bf14e1b4c.tar.gz
nextcloud-server-b40629ac8caf5d488053a9ab2e89210bf14e1b4c.zip
Add human readable description to migration steps
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/DB/MigrationService.php27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php
index 77ac23fe5d2..cc2889dae0c 100644
--- a/lib/private/DB/MigrationService.php
+++ b/lib/private/DB/MigrationService.php
@@ -387,14 +387,36 @@ class MigrationService {
}
/**
+ * Get the human readable descriptions for the migration steps to run
+ *
+ * @param string $to
+ * @return string[] [$name => $description]
+ */
+ public function describeMigrationStep($to = 'latest') {
+ $toBeExecuted = $this->getMigrationsToExecute($to);
+ $description = [];
+ foreach ($toBeExecuted as $version) {
+ $migration = $this->createInstance($version);
+ if ($migration->name()) {
+ $description[$migration->name()] = $migration->description();
+ }
+ }
+ return $description;
+ }
+
+ /**
* @param string $version
- * @return mixed
+ * @return IMigrationStep
* @throws \InvalidArgumentException
*/
protected function createInstance($version) {
$class = $this->getClass($version);
try {
$s = \OC::$server->query($class);
+
+ if (!$s instanceof IMigrationStep) {
+ throw new \InvalidArgumentException('Not a valid migration');
+ }
} catch (QueryException $e) {
if (class_exists($class)) {
$s = new $class();
@@ -414,9 +436,6 @@ class MigrationService {
*/
public function executeStep($version) {
$instance = $this->createInstance($version);
- if (!$instance instanceof IMigrationStep) {
- throw new \InvalidArgumentException('Not a valid migration');
- }
$instance->preSchemaChange($this->output, function() {
return new SchemaWrapper($this->connection);