Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
*/
namespace OCP\Migration\Attributes;

use JsonSerializable;

/**
* generic class related to migration attribute about column changes
*
* @since 30.0.0
*/
class ColumnMigrationAttribute extends MigrationAttribute implements JsonSerializable {
class ColumnMigrationAttribute extends MigrationAttribute {
/**
* @param string $table name of the database table
* @param string $name name of the column
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;

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

/**
* generic class related to migration attribute about data migration
*
* @since 32.0.0
*/
class DataMigrationAttribute extends MigrationAttribute {
Comment thread
nickvergessen marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
*/
namespace OCP\Migration\Attributes;

use JsonSerializable;

/**
* 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 {
class GenericMigrationAttribute extends MigrationAttribute {
/**
* @param array $details
* @since 30.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
*/
namespace OCP\Migration\Attributes;

use JsonSerializable;

/**
* generic class related to migration attribute about index changes
*
* @since 30.0.0
*/
class IndexMigrationAttribute extends MigrationAttribute implements JsonSerializable {
class IndexMigrationAttribute extends MigrationAttribute {
/**
* @param string $table name of the database table
* @param IndexType|null $type type of the index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
*/
namespace OCP\Migration\Attributes;

use JsonSerializable;

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