mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
feat(migration-attributes): add DataCleansing
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
parent
bc2321db94
commit
c86f2e948a
10 changed files with 58 additions and 12 deletions
|
|
@ -9,8 +9,11 @@ declare(strict_types=1);
|
|||
|
||||
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 {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ namespace OC\Core\Migrations;
|
|||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\Attributes\DataCleansing;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
|
@ -21,6 +22,8 @@ use Override;
|
|||
* 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,
|
||||
|
|
|
|||
|
|
@ -678,6 +678,8 @@ return array(
|
|||
'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',
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -8,14 +8,12 @@ declare(strict_types=1);
|
|||
*/
|
||||
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
|
||||
|
|
|
|||
27
lib/public/Migration/Attributes/DataCleansing.php
Normal file
27
lib/public/Migration/Attributes/DataCleansing.php
Normal file
|
|
@ -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 {
|
||||
/**
|
||||
* @return string
|
||||
* @since 32.0.0
|
||||
*/
|
||||
public function definition(): string {
|
||||
return 'Cleansing data from table \'' . $this->getTable() . '\'';
|
||||
}
|
||||
}
|
||||
17
lib/public/Migration/Attributes/DataMigrationAttribute.php
Normal file
17
lib/public/Migration/Attributes/DataMigrationAttribute.php
Normal file
|
|
@ -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 {
|
||||
}
|
||||
|
|
@ -8,15 +8,13 @@ declare(strict_types=1);
|
|||
*/
|
||||
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
|
||||
|
|
|
|||
|
|
@ -8,14 +8,12 @@ declare(strict_types=1);
|
|||
*/
|
||||
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
|
||||
|
|
|
|||
|
|
@ -8,14 +8,12 @@ declare(strict_types=1);
|
|||
*/
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue