Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\Attributes\CreateTable;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

#[CreateTable(table: 'federated_invites', columns: ['id', 'user_id', 'recipient_provider', 'recipient_user_id', 'recipient_name', 'recipient_email', 'token', 'accepted', 'created_at', 'expired_at', 'accepted_at'], description: 'Supporting the OCM Invitation Flow feature')]
class Version1016Date202502262004 extends SimpleMigrationStep {
/**
* @param IOutput $output
Expand Down
5 changes: 5 additions & 0 deletions apps/dav/lib/Migration/Version1034Date20250605132605.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\Attributes\AddColumn;
use OCP\Migration\Attributes\ColumnType;
use OCP\Migration\Attributes\CreateTable;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

#[AddColumn(table: 'dav_shares', name: 'token', type: ColumnType::STRING)]
#[CreateTable(table: 'calendars_federated', columns: ['id', 'display_name', 'color', 'uri', 'principaluri', 'remote_Url', 'token', 'sync_token', 'last_sync', 'shared_by', 'shared_by_display_name', 'components', 'permissions'], description: 'Supporting Federated Calender')]
class Version1034Date20250605132605 extends SimpleMigrationStep {
/**
* @param IOutput $output
Expand Down
2 changes: 2 additions & 0 deletions apps/dav/lib/Migration/Version1034Date20250813093701.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Migration\Attributes\DataCleansing;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Override;

#[DataCleansing(table: 'properties', description: 'remove commonly used custom properties set as default')]
class Version1034Date20250813093701 extends SimpleMigrationStep {
public function __construct(
private IDBConnection $db,
Expand Down
1 change: 1 addition & 0 deletions build/psalm/OcpSinceChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event): voi

$isTesting = str_contains($statementsSource->getFilePath(), '/lib/public/Notification/')
|| str_contains($statementsSource->getFilePath(), '/lib/public/Config/')
|| str_contains($statementsSource->getFilePath(), '/lib/public/Migration/Attributes/')
|| str_contains($statementsSource->getFilePath(), 'CalendarEventStatus');

if ($isTesting) {
Expand Down
3 changes: 3 additions & 0 deletions core/Migrations/Version32000Date20250620081925.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

namespace OC\Core\Migrations;

use OCP\Migration\Attributes\DataCleansing;

/**
* Run the old migration Version24000Date20211210141942 again.
*/
#[DataCleansing(table: 'preferences', description: 'lowercase accounts email address')]
class Version32000Date20250620081925 extends Version24000Date20211210141942 {
}
3 changes: 3 additions & 0 deletions core/Migrations/Version32000Date20250731062008.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\Attributes\DataCleansing;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Override;
Expand All @@ -21,6 +22,8 @@
* This migration will clean up existing duplicates.
* The new unique constraint is added in @see \OC\Core\Listener\AddMissingIndicesListener
*/
#[DataCleansing(table: 'vcategory', description: 'Cleanup of duplicate vcategory records')]
#[DataCleansing(table: 'vcategory_to_object', description: 'Update object references')]
class Version32000Date20250731062008 extends SimpleMigrationStep {
public function __construct(
private IDBConnection $connection,
Expand Down
2 changes: 2 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,8 @@
'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\\DataCleansing' => $baseDir . '/lib/public/Migration/Attributes/DataCleansing.php',
'OCP\\Migration\\Attributes\\DataMigrationAttribute' => $baseDir . '/lib/public/Migration/Attributes/DataMigrationAttribute.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',
Expand Down
2 changes: 2 additions & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'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\\DataCleansing' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/DataCleansing.php',
'OCP\\Migration\\Attributes\\DataMigrationAttribute' => __DIR__ . '/../../..' . '/lib/public/Migration/Attributes/DataMigrationAttribute.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',
Expand Down
4 changes: 2 additions & 2 deletions lib/public/Migration/Attributes/AddColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
namespace OCP\Migration\Attributes;

use Attribute;
use OCP\AppFramework\Attribute\Consumable;

/**
* attribute on new column creation
*
* @since 30.0.0
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
#[Consumable(since: '30.0.0')]
class AddColumn extends ColumnMigrationAttribute {
/**
* @return string
Expand Down
4 changes: 2 additions & 2 deletions lib/public/Migration/Attributes/AddIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
namespace OCP\Migration\Attributes;

use Attribute;
use OCP\AppFramework\Attribute\Consumable;

/**
* attribute on index creation
*
* @since 30.0.0
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
#[Consumable(since: '30.0.0')]
class AddIndex extends IndexMigrationAttribute {
/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
*/
namespace OCP\Migration\Attributes;

use JsonSerializable;
use OCP\AppFramework\Attribute\Consumable;

/**
* generic class related to migration attribute about column changes
*
* @since 30.0.0
*/
class ColumnMigrationAttribute extends MigrationAttribute implements JsonSerializable {
#[Consumable(since: '30.0.0')]
class ColumnMigrationAttribute extends MigrationAttribute {
/**
* @param string $table name of the database table
* @param string $name name of the column
Expand Down
4 changes: 3 additions & 1 deletion lib/public/Migration/Attributes/ColumnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
*/
namespace OCP\Migration\Attributes;

use OCP\AppFramework\Attribute\Consumable;

/**
* enum ColumnType based on OCP\DB\Types
*
* @see \OCP\DB\Types
* @since 30.0.0
*/
#[Consumable(since: '30.0.0')]
enum ColumnType : string {
/** @since 30.0.0 */
case BIGINT = 'bigint';
Expand Down
4 changes: 2 additions & 2 deletions lib/public/Migration/Attributes/CreateTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
namespace OCP\Migration\Attributes;

use Attribute;
use OCP\AppFramework\Attribute\Consumable;

/**
* attribute on table creation
*
* @since 30.0.0
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
#[Consumable(since: '30.0.0')]
class CreateTable extends TableMigrationAttribute {
/**
* @return string
Expand Down
27 changes: 27 additions & 0 deletions lib/public/Migration/Attributes/DataCleansing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Migration\Attributes;

use Attribute;
use OCP\AppFramework\Attribute\Consumable;

/**
* attribute on new column creation
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
#[Consumable(since: '32.0.0')]
class DataCleansing extends DataMigrationAttribute {
/**
* @return string
* @since 32.0.0
*/
public function definition(): string {
return 'Cleansing data from table \'' . $this->getTable() . '\'';
}
}
18 changes: 18 additions & 0 deletions lib/public/Migration/Attributes/DataMigrationAttribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Migration\Attributes;

use OCP\AppFramework\Attribute\Consumable;

/**
* generic class related to migration attribute about data migration
*/
#[Consumable(since: '32.0.0')]
class DataMigrationAttribute extends MigrationAttribute {
}
4 changes: 2 additions & 2 deletions lib/public/Migration/Attributes/DropColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
namespace OCP\Migration\Attributes;

use Attribute;
use OCP\AppFramework\Attribute\Consumable;

/**
* attribute on column drop
*
* @since 30.0.0
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
#[Consumable(since: '30.0.0')]
class DropColumn extends ColumnMigrationAttribute {
/**
* @return string
Expand Down
4 changes: 2 additions & 2 deletions lib/public/Migration/Attributes/DropIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
namespace OCP\Migration\Attributes;

use Attribute;
use OCP\AppFramework\Attribute\Consumable;

/**
* attribute on index drop
*
* @since 30.0.0
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
#[Consumable(since: '30.0.0')]
class DropIndex extends IndexMigrationAttribute {
/**
* @return string
Expand Down
4 changes: 2 additions & 2 deletions lib/public/Migration/Attributes/DropTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
namespace OCP\Migration\Attributes;

use Attribute;
use OCP\AppFramework\Attribute\Consumable;

/**
* attribute on table drop
*
* @since 30.0.0
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
#[Consumable(since: '30.0.0')]
class DropTable extends TableMigrationAttribute {
/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
*/
namespace OCP\Migration\Attributes;

use JsonSerializable;
use OCP\AppFramework\Attribute\Consumable;

/**
* generic entry, used to replace migration attribute not yet known in current version
* but used in a future release
*
* @since 30.0.0
*/
class GenericMigrationAttribute extends MigrationAttribute implements JsonSerializable {
#[Consumable(since: '30.0.0')]
class GenericMigrationAttribute extends MigrationAttribute {
/**
* @param array $details
* @since 30.0.0
Expand Down
7 changes: 3 additions & 4 deletions lib/public/Migration/Attributes/IndexMigrationAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
*/
namespace OCP\Migration\Attributes;

use JsonSerializable;
use OCP\AppFramework\Attribute\Consumable;

/**
* generic class related to migration attribute about index changes
*
* @since 30.0.0
*/
class IndexMigrationAttribute extends MigrationAttribute implements JsonSerializable {
#[Consumable(since: '30.0.0')]
class IndexMigrationAttribute extends MigrationAttribute {
/**
* @param string $table name of the database table
* @param IndexType|null $type type of the index
Expand Down
5 changes: 3 additions & 2 deletions lib/public/Migration/Attributes/IndexType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
*/
namespace OCP\Migration\Attributes;

use OCP\AppFramework\Attribute\Consumable;

/**
* type of index
*
* @since 30.0.0
*/
#[Consumable(since: '30.0.0')]
enum IndexType : string {
/** @since 30.0.0 */
case PRIMARY = 'primary';
Expand Down
5 changes: 2 additions & 3 deletions lib/public/Migration/Attributes/MigrationAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
namespace OCP\Migration\Attributes;

use JsonSerializable;
use OCP\AppFramework\Attribute\Consumable;

/**
* @since 30.0.0
*/
#[Consumable(since: '30.0.0')]
class MigrationAttribute implements JsonSerializable {
/**
* @param string $table name of the database table
Expand Down
4 changes: 2 additions & 2 deletions lib/public/Migration/Attributes/ModifyColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
namespace OCP\Migration\Attributes;

use Attribute;
use OCP\AppFramework\Attribute\Consumable;

/**
* attribute on column modification
*
* @since 30.0.0
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
#[Consumable(since: '30.0.0')]
class ModifyColumn extends ColumnMigrationAttribute {
/**
* @return string
Expand Down
7 changes: 3 additions & 4 deletions lib/public/Migration/Attributes/TableMigrationAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
*/
namespace OCP\Migration\Attributes;

use JsonSerializable;
use OCP\AppFramework\Attribute\Consumable;

/**
* generic class related to migration attribute about table changes
*
* @since 30.0.0
*/
class TableMigrationAttribute extends MigrationAttribute implements JsonSerializable {
#[Consumable(since: '30.0.0')]
class TableMigrationAttribute extends MigrationAttribute {
/**
* @param string $table name of the database table
* @param array $columns list of columns
Expand Down
Loading