aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/Command/Db/Migrations/GenerateMetadataCommand.php7
-rw-r--r--core/Command/Db/Migrations/PreviewCommand.php3
-rw-r--r--lib/composer/composer/autoload_classmap.php10
-rw-r--r--lib/composer/composer/autoload_static.php10
-rw-r--r--lib/private/Migration/Exceptions/AttributeException.php (renamed from lib/public/Migration/Exceptions/AttributeException.php)2
-rw-r--r--lib/private/Migration/MetadataManager.php8
-rw-r--r--lib/public/Migration/Attributes/AddColumn.php7
-rw-r--r--lib/public/Migration/Attributes/AddIndex.php7
-rw-r--r--lib/public/Migration/Attributes/ColumnMigrationAttribute.php33
-rw-r--r--lib/public/Migration/Attributes/CreateTable.php9
-rw-r--r--lib/public/Migration/Attributes/DropColumn.php7
-rw-r--r--lib/public/Migration/Attributes/DropIndex.php7
-rw-r--r--lib/public/Migration/Attributes/DropTable.php (renamed from lib/public/Migration/Attributes/DeleteTable.php)11
-rw-r--r--lib/public/Migration/Attributes/GenericMigrationAttribute.php11
-rw-r--r--lib/public/Migration/Attributes/IndexMigrationAttribute.php23
-rw-r--r--lib/public/Migration/Attributes/IndexType.php6
-rw-r--r--lib/public/Migration/Attributes/MigrationAttribute.php47
-rw-r--r--lib/public/Migration/Attributes/ModifyColumn.php7
-rw-r--r--lib/public/Migration/Attributes/TableMigrationAttribute.php25
19 files changed, 215 insertions, 25 deletions
diff --git a/core/Command/Db/Migrations/GenerateMetadataCommand.php b/core/Command/Db/Migrations/GenerateMetadataCommand.php
index 64840bea230..55a2a6aedab 100644
--- a/core/Command/Db/Migrations/GenerateMetadataCommand.php
+++ b/core/Command/Db/Migrations/GenerateMetadataCommand.php
@@ -14,6 +14,9 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+/**
+ * @since 30.0.0
+ */
class GenerateMetadataCommand extends Command {
public function __construct(
private readonly MetadataManager $metadataManager,
@@ -43,9 +46,7 @@ class GenerateMetadataCommand extends Command {
return 0;
}
-
-
- public function extractMigrationMetadata(): array {
+ private function extractMigrationMetadata(): array {
return [
'core' => $this->extractMigrationMetadataFromCore(),
'apps' => $this->extractMigrationMetadataFromApps()
diff --git a/core/Command/Db/Migrations/PreviewCommand.php b/core/Command/Db/Migrations/PreviewCommand.php
index b1881a0c42c..e35100dacb2 100644
--- a/core/Command/Db/Migrations/PreviewCommand.php
+++ b/core/Command/Db/Migrations/PreviewCommand.php
@@ -20,6 +20,9 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+/**
+ * @since 30.0.0
+ */
class PreviewCommand extends Command {
private bool $initiated = false;
public function __construct(
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index a167eba878f..8a1cd5514d4 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -572,7 +572,6 @@ return array(
'OCP\\Mail\\IEMailTemplate' => $baseDir . '/lib/public/Mail/IEMailTemplate.php',
'OCP\\Mail\\IMailer' => $baseDir . '/lib/public/Mail/IMailer.php',
'OCP\\Mail\\IMessage' => $baseDir . '/lib/public/Mail/IMessage.php',
-<<<<<<< HEAD
'OCP\\Mail\\Provider\\Address' => $baseDir . '/lib/public/Mail/Provider/Address.php',
'OCP\\Mail\\Provider\\Attachment' => $baseDir . '/lib/public/Mail/Provider/Attachment.php',
'OCP\\Mail\\Provider\\Exception\\Exception' => $baseDir . '/lib/public/Mail/Provider/Exception/Exception.php',
@@ -585,24 +584,21 @@ return array(
'OCP\\Mail\\Provider\\IProvider' => $baseDir . '/lib/public/Mail/Provider/IProvider.php',
'OCP\\Mail\\Provider\\IService' => $baseDir . '/lib/public/Mail/Provider/IService.php',
'OCP\\Mail\\Provider\\Message' => $baseDir . '/lib/public/Mail/Provider/Message.php',
-=======
'OCP\\Migration\\Attributes\\AddColumn' => $baseDir . '/lib/public/Migration/Attributes/AddColumn.php',
'OCP\\Migration\\Attributes\\AddIndex' => $baseDir . '/lib/public/Migration/Attributes/AddIndex.php',
'OCP\\Migration\\Attributes\\ColumnMigrationAttribute' => $baseDir . '/lib/public/Migration/Attributes/ColumnMigrationAttribute.php',
'OCP\\Migration\\Attributes\\ColumnType' => $baseDir . '/lib/public/Migration/Attributes/ColumnType.php',
'OCP\\Migration\\Attributes\\CreateTable' => $baseDir . '/lib/public/Migration/Attributes/CreateTable.php',
- 'OCP\\Migration\\Attributes\\DeleteTable' => $baseDir . '/lib/public/Migration/Attributes/DeleteTable.php',
'OCP\\Migration\\Attributes\\DropColumn' => $baseDir . '/lib/public/Migration/Attributes/DropColumn.php',
'OCP\\Migration\\Attributes\\DropIndex' => $baseDir . '/lib/public/Migration/Attributes/DropIndex.php',
+ 'OCP\\Migration\\Attributes\\DropTable' => $baseDir . '/lib/public/Migration/Attributes/DropTable.php',
'OCP\\Migration\\Attributes\\GenericMigrationAttribute' => $baseDir . '/lib/public/Migration/Attributes/GenericMigrationAttribute.php',
'OCP\\Migration\\Attributes\\IndexMigrationAttribute' => $baseDir . '/lib/public/Migration/Attributes/IndexMigrationAttribute.php',
'OCP\\Migration\\Attributes\\IndexType' => $baseDir . '/lib/public/Migration/Attributes/IndexType.php',
'OCP\\Migration\\Attributes\\MigrationAttribute' => $baseDir . '/lib/public/Migration/Attributes/MigrationAttribute.php',
'OCP\\Migration\\Attributes\\ModifyColumn' => $baseDir . '/lib/public/Migration/Attributes/ModifyColumn.php',
'OCP\\Migration\\Attributes\\TableMigrationAttribute' => $baseDir . '/lib/public/Migration/Attributes/TableMigrationAttribute.php',
->>>>>>> 2f771df35a9 (feat(upgrade): migration attributes)
'OCP\\Migration\\BigIntMigration' => $baseDir . '/lib/public/Migration/BigIntMigration.php',
- 'OCP\\Migration\\Exceptions\\AttributeException' => $baseDir . '/lib/public/Migration/Exceptions/AttributeException.php',
'OCP\\Migration\\IMigrationStep' => $baseDir . '/lib/public/Migration/IMigrationStep.php',
'OCP\\Migration\\IOutput' => $baseDir . '/lib/public/Migration/IOutput.php',
'OCP\\Migration\\IRepairStep' => $baseDir . '/lib/public/Migration/IRepairStep.php',
@@ -1672,6 +1668,8 @@ return array(
'OC\\MemoryInfo' => $baseDir . '/lib/private/MemoryInfo.php',
'OC\\Migration\\BackgroundRepair' => $baseDir . '/lib/private/Migration/BackgroundRepair.php',
'OC\\Migration\\ConsoleOutput' => $baseDir . '/lib/private/Migration/ConsoleOutput.php',
+ 'OC\\Migration\\Exceptions\\AttributeException' => $baseDir . '/lib/private/Migration/Exceptions/AttributeException.php',
+ 'OC\\Migration\\MetadataManager' => $baseDir . '/lib/private/Migration/MetadataManager.php',
'OC\\Migration\\NullOutput' => $baseDir . '/lib/private/Migration/NullOutput.php',
'OC\\Migration\\SimpleOutput' => $baseDir . '/lib/private/Migration/SimpleOutput.php',
'OC\\NaturalSort' => $baseDir . '/lib/private/NaturalSort.php',
@@ -1961,6 +1959,8 @@ return array(
'OC\\Updater\\Changes' => $baseDir . '/lib/private/Updater/Changes.php',
'OC\\Updater\\ChangesCheck' => $baseDir . '/lib/private/Updater/ChangesCheck.php',
'OC\\Updater\\ChangesMapper' => $baseDir . '/lib/private/Updater/ChangesMapper.php',
+ 'OC\\Updater\\Exceptions\\ReleaseMetadataException' => $baseDir . '/lib/private/Updater/Exceptions/ReleaseMetadataException.php',
+ 'OC\\Updater\\ReleaseMetadata' => $baseDir . '/lib/private/Updater/ReleaseMetadata.php',
'OC\\Updater\\VersionCheck' => $baseDir . '/lib/private/Updater/VersionCheck.php',
'OC\\UserStatus\\ISettableProvider' => $baseDir . '/lib/private/UserStatus/ISettableProvider.php',
'OC\\UserStatus\\Manager' => $baseDir . '/lib/private/UserStatus/Manager.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index b328d6ff5c9..7c824b34160 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -605,7 +605,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Mail\\IEMailTemplate' => __DIR__ . '/../../..' . '/lib/public/Mail/IEMailTemplate.php',
'OCP\\Mail\\IMailer' => __DIR__ . '/../../..' . '/lib/public/Mail/IMailer.php',
'OCP\\Mail\\IMessage' => __DIR__ . '/../../..' . '/lib/public/Mail/IMessage.php',
-<<<<<<< HEAD
'OCP\\Mail\\Provider\\Address' => __DIR__ . '/../../..' . '/lib/public/Mail/Provider/Address.php',
'OCP\\Mail\\Provider\\Attachment' => __DIR__ . '/../../..' . '/lib/public/Mail/Provider/Attachment.php',
'OCP\\Mail\\Provider\\Exception\\Exception' => __DIR__ . '/../../..' . '/lib/public/Mail/Provider/Exception/Exception.php',
@@ -618,24 +617,21 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Mail\\Provider\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Mail/Provider/IProvider.php',
'OCP\\Mail\\Provider\\IService' => __DIR__ . '/../../..' . '/lib/public/Mail/Provider/IService.php',
'OCP\\Mail\\Provider\\Message' => __DIR__ . '/../../..' . '/lib/public/Mail/Provider/Message.php',
-=======
'OCP\\Migration\\Attributes\\AddColumn' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/AddColumn.php',
'OCP\\Migration\\Attributes\\AddIndex' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/AddIndex.php',
'OCP\\Migration\\Attributes\\ColumnMigrationAttribute' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/ColumnMigrationAttribute.php',
'OCP\\Migration\\Attributes\\ColumnType' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/ColumnType.php',
'OCP\\Migration\\Attributes\\CreateTable' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/CreateTable.php',
- 'OCP\\Migration\\Attributes\\DeleteTable' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/DeleteTable.php',
'OCP\\Migration\\Attributes\\DropColumn' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/DropColumn.php',
'OCP\\Migration\\Attributes\\DropIndex' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/DropIndex.php',
+ 'OCP\\Migration\\Attributes\\DropTable' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/DropTable.php',
'OCP\\Migration\\Attributes\\GenericMigrationAttribute' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/GenericMigrationAttribute.php',
'OCP\\Migration\\Attributes\\IndexMigrationAttribute' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/IndexMigrationAttribute.php',
'OCP\\Migration\\Attributes\\IndexType' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/IndexType.php',
'OCP\\Migration\\Attributes\\MigrationAttribute' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/MigrationAttribute.php',
'OCP\\Migration\\Attributes\\ModifyColumn' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/ModifyColumn.php',
'OCP\\Migration\\Attributes\\TableMigrationAttribute' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/TableMigrationAttribute.php',
->>>>>>> 2f771df35a9 (feat(upgrade): migration attributes)
'OCP\\Migration\\BigIntMigration' => __DIR__ . '/../../..' . '/lib/public/Migration/BigIntMigration.php',
- 'OCP\\Migration\\Exceptions\\AttributeException' => __DIR__ . '/../../..' . '/lib/public/Migration/Exceptions/AttributeException.php',
'OCP\\Migration\\IMigrationStep' => __DIR__ . '/../../..' . '/lib/public/Migration/IMigrationStep.php',
'OCP\\Migration\\IOutput' => __DIR__ . '/../../..' . '/lib/public/Migration/IOutput.php',
'OCP\\Migration\\IRepairStep' => __DIR__ . '/../../..' . '/lib/public/Migration/IRepairStep.php',
@@ -1705,6 +1701,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\MemoryInfo' => __DIR__ . '/../../..' . '/lib/private/MemoryInfo.php',
'OC\\Migration\\BackgroundRepair' => __DIR__ . '/../../..' . '/lib/private/Migration/BackgroundRepair.php',
'OC\\Migration\\ConsoleOutput' => __DIR__ . '/../../..' . '/lib/private/Migration/ConsoleOutput.php',
+ 'OC\\Migration\\Exceptions\\AttributeException' => __DIR__ . '/../../..' . '/lib/private/Migration/Exceptions/AttributeException.php',
+ 'OC\\Migration\\MetadataManager' => __DIR__ . '/../../..' . '/lib/private/Migration/MetadataManager.php',
'OC\\Migration\\NullOutput' => __DIR__ . '/../../..' . '/lib/private/Migration/NullOutput.php',
'OC\\Migration\\SimpleOutput' => __DIR__ . '/../../..' . '/lib/private/Migration/SimpleOutput.php',
'OC\\NaturalSort' => __DIR__ . '/../../..' . '/lib/private/NaturalSort.php',
@@ -1994,6 +1992,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Updater\\Changes' => __DIR__ . '/../../..' . '/lib/private/Updater/Changes.php',
'OC\\Updater\\ChangesCheck' => __DIR__ . '/../../..' . '/lib/private/Updater/ChangesCheck.php',
'OC\\Updater\\ChangesMapper' => __DIR__ . '/../../..' . '/lib/private/Updater/ChangesMapper.php',
+ 'OC\\Updater\\Exceptions\\ReleaseMetadataException' => __DIR__ . '/../../..' . '/lib/private/Updater/Exceptions/ReleaseMetadataException.php',
+ 'OC\\Updater\\ReleaseMetadata' => __DIR__ . '/../../..' . '/lib/private/Updater/ReleaseMetadata.php',
'OC\\Updater\\VersionCheck' => __DIR__ . '/../../..' . '/lib/private/Updater/VersionCheck.php',
'OC\\UserStatus\\ISettableProvider' => __DIR__ . '/../../..' . '/lib/private/UserStatus/ISettableProvider.php',
'OC\\UserStatus\\Manager' => __DIR__ . '/../../..' . '/lib/private/UserStatus/Manager.php',
diff --git a/lib/public/Migration/Exceptions/AttributeException.php b/lib/private/Migration/Exceptions/AttributeException.php
index 92de70f3e96..3daf99032ad 100644
--- a/lib/public/Migration/Exceptions/AttributeException.php
+++ b/lib/private/Migration/Exceptions/AttributeException.php
@@ -6,7 +6,7 @@ declare(strict_types=1);
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-namespace OCP\Migration\Exceptions;
+namespace OC\Migration\Exceptions;
use Exception;
diff --git a/lib/private/Migration/MetadataManager.php b/lib/private/Migration/MetadataManager.php
index c5061b6fe0c..2558d49f7f8 100644
--- a/lib/private/Migration/MetadataManager.php
+++ b/lib/private/Migration/MetadataManager.php
@@ -10,10 +10,10 @@ namespace OC\Migration;
use OC\DB\Connection;
use OC\DB\MigrationService;
+use OC\Migration\Exceptions\AttributeException;
use OCP\App\IAppManager;
use OCP\Migration\Attributes\GenericMigrationAttribute;
use OCP\Migration\Attributes\MigrationAttribute;
-use OCP\Migration\Exceptions\AttributeException;
use Psr\Log\LoggerInterface;
use ReflectionClass;
@@ -58,10 +58,10 @@ class MetadataManager {
/**
* convert direct data from release metadata into a list of Migrations' Attribute
*
- * @param array $metadata
+ * @param array<array-key, array<array-key, array>> $metadata
* @param bool $filterKnownMigrations ignore metadata already done in local instance
*
- * @return array
+ * @return array{apps: array<array-key, array<string, MigrationAttribute[]>>, core: array<string, MigrationAttribute[]>}
* @since 30.0.0
*/
public function getMigrationsAttributesFromReleaseMetadata(
@@ -73,6 +73,7 @@ class MetadataManager {
if ($filterKnownMigrations && !$this->appManager->isInstalled($appId)) {
continue; // if not interested and app is not installed
}
+
$done = ($filterKnownMigrations) ? $this->getKnownMigrations($appId) : [];
$appsAttributes[$appId] = $this->parseMigrations($metadata['apps'][$appId] ?? [], $done);
}
@@ -126,7 +127,6 @@ class MetadataManager {
return $ms->getMigratedVersions();
}
-
/**
* generate (deserialize) a MigrationAttribute from a serialized version
*
diff --git a/lib/public/Migration/Attributes/AddColumn.php b/lib/public/Migration/Attributes/AddColumn.php
index aadf3263b31..14a43c26f99 100644
--- a/lib/public/Migration/Attributes/AddColumn.php
+++ b/lib/public/Migration/Attributes/AddColumn.php
@@ -10,8 +10,15 @@ namespace OCP\Migration\Attributes;
use Attribute;
+/**
+ * @since 30.0.0
+ */
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
class AddColumn extends ColumnMigrationAttribute {
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function definition(): string {
$type = is_null($this->getType()) ? '' : ' (' . $this->getType()->value . ')';
$table = empty($this->getTable()) ? '' : ' to table \'' . $this->getTable() . '\'';
diff --git a/lib/public/Migration/Attributes/AddIndex.php b/lib/public/Migration/Attributes/AddIndex.php
index 9c96cd49a12..2a6f0628db1 100644
--- a/lib/public/Migration/Attributes/AddIndex.php
+++ b/lib/public/Migration/Attributes/AddIndex.php
@@ -10,8 +10,15 @@ namespace OCP\Migration\Attributes;
use Attribute;
+/**
+ * @since 30.0.0
+ */
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
class AddIndex extends IndexMigrationAttribute {
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function definition(): string {
$type = is_null($this->getType()) ? '' : ' (' . $this->getType()->value . ')';
$table = empty($this->getTable()) ? '' : ' to table \'' . $this->getTable() . '\'';
diff --git a/lib/public/Migration/Attributes/ColumnMigrationAttribute.php b/lib/public/Migration/Attributes/ColumnMigrationAttribute.php
index 6862f73e11d..dab636a3aaa 100644
--- a/lib/public/Migration/Attributes/ColumnMigrationAttribute.php
+++ b/lib/public/Migration/Attributes/ColumnMigrationAttribute.php
@@ -10,6 +10,9 @@ namespace OCP\Migration\Attributes;
use JsonSerializable;
+/**
+ * @since 30.0.0
+ */
class ColumnMigrationAttribute extends MigrationAttribute implements JsonSerializable {
public function __construct(
string $table = '',
@@ -21,24 +24,50 @@ class ColumnMigrationAttribute extends MigrationAttribute implements JsonSeriali
parent::__construct($table, $description, $notes);
}
+ /**
+ * @param string $name
+ *
+ * @return $this
+ * @since 30.0.0
+ */
public function setName(string $name): self {
$this->name = $name;
return $this;
}
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function getName(): string {
return $this->name;
}
+ /**
+ * @param ColumnType|null $type
+ *
+ * @return $this
+ * @since 30.0.0
+ */
public function setType(?ColumnType $type): self {
$this->type = $type;
return $this;
}
+ /**
+ * @return ColumnType|null
+ * @since 30.0.0
+ */
public function getType(): ?ColumnType {
return $this->type;
}
+ /**
+ * @param array $data
+ *
+ * @return $this
+ * @since 30.0.0
+ */
public function import(array $data): self {
parent::import($data);
$this->setName($data['name'] ?? '');
@@ -46,6 +75,10 @@ class ColumnMigrationAttribute extends MigrationAttribute implements JsonSeriali
return $this;
}
+ /**
+ * @return array
+ * @since 30.0.0
+ */
public function jsonSerialize(): array {
return array_merge(
parent::jsonSerialize(),
diff --git a/lib/public/Migration/Attributes/CreateTable.php b/lib/public/Migration/Attributes/CreateTable.php
index 600d9bf4b9f..8aac8cf247e 100644
--- a/lib/public/Migration/Attributes/CreateTable.php
+++ b/lib/public/Migration/Attributes/CreateTable.php
@@ -10,10 +10,17 @@ namespace OCP\Migration\Attributes;
use Attribute;
+/**
+ * @since 30.0.0
+ */
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
class CreateTable extends TableMigrationAttribute {
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function definition(): string {
- $definition = empty($this->getTable()) ? 'Creation of a new table' : 'Creation of new table \'' . $this->getTable() . '\'';
+ $definition = 'Creation of new table \'' . $this->getTable() . '\'';
$definition .= empty($this->getColumns()) ? '' : ' with columns ' . implode(', ', $this->getColumns());
return $definition;
}
diff --git a/lib/public/Migration/Attributes/DropColumn.php b/lib/public/Migration/Attributes/DropColumn.php
index dfa1e81b315..0bb3efb1917 100644
--- a/lib/public/Migration/Attributes/DropColumn.php
+++ b/lib/public/Migration/Attributes/DropColumn.php
@@ -10,8 +10,15 @@ namespace OCP\Migration\Attributes;
use Attribute;
+/**
+ * @since 30.0.0
+ */
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
class DropColumn extends ColumnMigrationAttribute {
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function definition(): string {
$table = empty($this->getTable()) ? '' : ' from table \'' . $this->getTable() . '\'';
return empty($this->getName()) ?
diff --git a/lib/public/Migration/Attributes/DropIndex.php b/lib/public/Migration/Attributes/DropIndex.php
index cbeea4f5997..0e72908ac35 100644
--- a/lib/public/Migration/Attributes/DropIndex.php
+++ b/lib/public/Migration/Attributes/DropIndex.php
@@ -10,8 +10,15 @@ namespace OCP\Migration\Attributes;
use Attribute;
+/**
+ * @since 30.0.0
+ */
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
class DropIndex extends IndexMigrationAttribute {
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function definition(): string {
return empty($this->getTable()) ?
'Deletion of an index'
diff --git a/lib/public/Migration/Attributes/DeleteTable.php b/lib/public/Migration/Attributes/DropTable.php
index 97bd36e385e..5741af14108 100644
--- a/lib/public/Migration/Attributes/DeleteTable.php
+++ b/lib/public/Migration/Attributes/DropTable.php
@@ -10,9 +10,16 @@ namespace OCP\Migration\Attributes;
use Attribute;
+/**
+ *
+ */
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
-class DeleteTable extends MigrationAttribute {
+class DropTable extends TableMigrationAttribute {
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function definition(): string {
- return empty($this->getTable()) ? 'Deletion of a table' : 'Deletion of table \'' . $this->getTable() . '\'';
+ return 'Deletion of table \'' . $this->getTable() . '\'';
}
}
diff --git a/lib/public/Migration/Attributes/GenericMigrationAttribute.php b/lib/public/Migration/Attributes/GenericMigrationAttribute.php
index f0e3af97615..1f40d77d1f1 100644
--- a/lib/public/Migration/Attributes/GenericMigrationAttribute.php
+++ b/lib/public/Migration/Attributes/GenericMigrationAttribute.php
@@ -10,6 +10,9 @@ namespace OCP\Migration\Attributes;
use JsonSerializable;
+/**
+ * @since 30.0.0
+ */
class GenericMigrationAttribute extends MigrationAttribute implements JsonSerializable {
public function __construct(
private readonly array $details = []
@@ -21,10 +24,18 @@ class GenericMigrationAttribute extends MigrationAttribute implements JsonSerial
);
}
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function definition(): string {
return json_encode($this->jsonSerialize(), JSON_UNESCAPED_SLASHES);
}
+ /**
+ * @return array
+ * @since 30.0.0
+ */
public function jsonSerialize(): array {
return $this->details;
}
diff --git a/lib/public/Migration/Attributes/IndexMigrationAttribute.php b/lib/public/Migration/Attributes/IndexMigrationAttribute.php
index fbe636bd6b0..33c5177c8ac 100644
--- a/lib/public/Migration/Attributes/IndexMigrationAttribute.php
+++ b/lib/public/Migration/Attributes/IndexMigrationAttribute.php
@@ -10,6 +10,9 @@ namespace OCP\Migration\Attributes;
use JsonSerializable;
+/**
+ * @since 30.0.0
+ */
class IndexMigrationAttribute extends MigrationAttribute implements JsonSerializable {
public function __construct(
string $table = '',
@@ -20,21 +23,41 @@ class IndexMigrationAttribute extends MigrationAttribute implements JsonSerializ
parent::__construct($table, $description, $notes);
}
+ /**
+ * @param IndexType|null $type
+ *
+ * @return $this
+ * @since 30.0.0
+ */
public function setType(?IndexType $type): self {
$this->type = $type;
return $this;
}
+ /**
+ * @return IndexType|null
+ * @since 30.0.0
+ */
public function getType(): ?IndexType {
return $this->type;
}
+ /**
+ * @param array $data
+ *
+ * @return $this
+ * @since 30.0.0
+ */
public function import(array $data): self {
parent::import($data);
$this->setType(IndexType::tryFrom($data['type'] ?? ''));
return $this;
}
+ /**
+ * @return array
+ * @since 30.0.0
+ */
public function jsonSerialize(): array {
return array_merge(
parent::jsonSerialize(),
diff --git a/lib/public/Migration/Attributes/IndexType.php b/lib/public/Migration/Attributes/IndexType.php
index 842f135e700..b957aebafa7 100644
--- a/lib/public/Migration/Attributes/IndexType.php
+++ b/lib/public/Migration/Attributes/IndexType.php
@@ -13,9 +13,9 @@ namespace OCP\Migration\Attributes;
*/
enum IndexType : string {
/** @since 30.0.0 */
- case PRIMARY = 'primary'; // migration is estimated to require few minutes
+ case PRIMARY = 'primary';
/** @since 30.0.0 */
- case INDEX = 'index'; // depends on setup, migration might require some time
+ case INDEX = 'index';
/** @since 30.0.0 */
- case UNIQUE = 'unique'; // migration should be light and quick
+ case UNIQUE = 'unique';
}
diff --git a/lib/public/Migration/Attributes/MigrationAttribute.php b/lib/public/Migration/Attributes/MigrationAttribute.php
index 9f88614e37d..b9d698241d4 100644
--- a/lib/public/Migration/Attributes/MigrationAttribute.php
+++ b/lib/public/Migration/Attributes/MigrationAttribute.php
@@ -10,6 +10,9 @@ namespace OCP\Migration\Attributes;
use JsonSerializable;
+/**
+ * @since 30.0.0
+ */
class MigrationAttribute implements JsonSerializable {
public function __construct(
private string $table = '',
@@ -18,43 +21,87 @@ class MigrationAttribute implements JsonSerializable {
) {
}
+ /**
+ * @param string $table
+ *
+ * @return $this
+ * @since 30.0.0
+ */
public function setTable(string $table): self {
$this->table = $table;
return $this;
}
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function getTable(): string {
return $this->table;
}
+ /**
+ * @param string $description
+ *
+ * @return $this
+ * @since 30.0.0
+ */
public function setDescription(string $description): self {
$this->description = $description;
return $this;
}
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function getDescription(): string {
return $this->description;
}
+ /**
+ * @param array $notes
+ *
+ * @return $this
+ * @since 30.0.0
+ */
public function setNotes(array $notes): self {
$this->notes = $notes;
return $this;
}
+ /**
+ * @return array
+ * @since 30.0.0
+ */
public function getNotes(): array {
return $this->notes;
}
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function definition(): string {
return json_encode($this->jsonSerialize(), JSON_UNESCAPED_SLASHES);
}
+ /**
+ * @param array $data
+ *
+ * @return self
+ * @since 30.0.0
+ */
public function import(array $data): self {
return $this->setTable($data['table'] ?? '')
->setDescription($data['description'] ?? '')
->setNotes($data['notes'] ?? []);
}
+ /**
+ * @return array
+ * @since 30.0.0
+ */
public function jsonSerialize(): array {
return [
'class' => get_class($this),
diff --git a/lib/public/Migration/Attributes/ModifyColumn.php b/lib/public/Migration/Attributes/ModifyColumn.php
index e73b10478f7..216a911d90f 100644
--- a/lib/public/Migration/Attributes/ModifyColumn.php
+++ b/lib/public/Migration/Attributes/ModifyColumn.php
@@ -10,8 +10,15 @@ namespace OCP\Migration\Attributes;
use Attribute;
+/**
+ * @since 30.0.0
+ */
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
class ModifyColumn extends ColumnMigrationAttribute {
+ /**
+ * @return string
+ * @since 30.0.0
+ */
public function definition(): string {
$type = is_null($this->getType()) ? '' : ' to ' . $this->getType()->value;
$table = empty($this->getTable()) ? '' : ' from table \'' . $this->getTable() . '\'';
diff --git a/lib/public/Migration/Attributes/TableMigrationAttribute.php b/lib/public/Migration/Attributes/TableMigrationAttribute.php
index 1c3f90c6acf..571173b9ba1 100644
--- a/lib/public/Migration/Attributes/TableMigrationAttribute.php
+++ b/lib/public/Migration/Attributes/TableMigrationAttribute.php
@@ -10,9 +10,12 @@ namespace OCP\Migration\Attributes;
use JsonSerializable;
+/**
+ * @since 30.0.0
+ */
class TableMigrationAttribute extends MigrationAttribute implements JsonSerializable {
public function __construct(
- string $table = '',
+ string $table,
private array $columns = [],
string $description = '',
array $notes = [],
@@ -20,21 +23,41 @@ class TableMigrationAttribute extends MigrationAttribute implements JsonSerializ
parent::__construct($table, $description, $notes);
}
+ /**
+ * @param array $columns
+ *
+ * @return $this
+ * @since 30.0.0
+ */
public function setColumns(array $columns): self {
$this->columns = $columns;
return $this;
}
+ /**
+ * @return array
+ * @since 30.0.0
+ */
public function getColumns(): array {
return $this->columns;
}
+ /**
+ * @param array $data
+ *
+ * @return $this
+ * @since 30.0.0
+ */
public function import(array $data): self {
parent::import($data);
$this->setColumns($data['columns'] ?? []);
return $this;
}
+ /**
+ * @return array
+ * @since 30.0.0
+ */
public function jsonSerialize(): array {
return array_merge(
parent::jsonSerialize(),