mirror of
https://github.com/nextcloud/server.git
synced 2026-02-19 02:38:40 -05:00
refactor(psalm): Modernize migration doc
And remove all the duplication in the subclasses Signed-off-by: Carl Schwan <carlschwan@kde.org>
This commit is contained in:
parent
4d6959da27
commit
f6c839d125
26 changed files with 83 additions and 183 deletions
|
|
@ -17,21 +17,17 @@ use OCP\DB\Types;
|
|||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
class Version1025Date20240308063933 extends SimpleMigrationStep {
|
||||
|
||||
public function __construct(
|
||||
private IAppConfig $appConfig,
|
||||
private IDBConnection $db,
|
||||
private readonly IAppConfig $appConfig,
|
||||
private readonly IDBConnection $db,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
@ -50,6 +46,7 @@ class Version1025Date20240308063933 extends SimpleMigrationStep {
|
|||
return $schema;
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
|
||||
// The threshold is higher than the default of \OCA\DAV\BackgroundJob\PruneOutdatedSyncTokensJob
|
||||
// but small enough to fit into a cluster transaction size.
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ namespace OCA\DAV\Migration;
|
|||
|
||||
use Closure;
|
||||
use OCA\DAV\CardDAV\SyncService;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IConfig;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
|
||||
|
|
@ -27,11 +27,8 @@ class Version1027Date20230504122946 extends SimpleMigrationStep {
|
|||
private IConfig $config,
|
||||
) {
|
||||
}
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
*/
|
||||
|
||||
#[Override]
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||
if ($this->userManager->countSeenUsers() > 100 || $this->userManager->countUsersTotal(100) >= 100) {
|
||||
$this->config->setAppValue('dav', 'needs_system_address_book_sync', 'yes');
|
||||
|
|
|
|||
|
|
@ -12,16 +12,14 @@ namespace OCA\DAV\Migration;
|
|||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\DB\Types;
|
||||
use OCP\Migration\Attributes\CreateTable;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
#[CreateTable(table: 'dav_absence')]
|
||||
class Version1029Date20231004091403 extends SimpleMigrationStep {
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
|||
|
|
@ -11,17 +11,14 @@ namespace OCA\DAV\Migration;
|
|||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\Attributes\DropIndex;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
#[DropIndex(table: 'cards')]
|
||||
class Version1030Date20240205103243 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
|||
|
|
@ -17,16 +17,12 @@ use OCP\Migration\Attributes\ColumnType;
|
|||
use OCP\Migration\Attributes\CreateTable;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
#[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
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ declare(strict_types=1);
|
|||
namespace OCA\DAV\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\Attributes\DataCleansing;
|
||||
|
|
@ -25,11 +24,6 @@ class Version1034Date20250813093701 extends SimpleMigrationStep {
|
|||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
*/
|
||||
#[Override]
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ use Override;
|
|||
#[ModifyColumn(table: 'calendar_reminders', name: 'uid', type: ColumnType::STRING, description: 'Increase uid length to 512 characters')]
|
||||
#[ModifyColumn(table: 'calendar_invitations', name: 'uid', type: ColumnType::STRING, description: 'Increase uid length to 512 characters')]
|
||||
class Version1036Date20251202000000 extends SimpleMigrationStep {
|
||||
/**
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
|
|
|
|||
|
|
@ -11,26 +11,26 @@ namespace OCA\Files\Migration;
|
|||
|
||||
use Closure;
|
||||
use OCA\Files\Service\ChunkedUploadConfig;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IConfig;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use OCP\Server;
|
||||
use Override;
|
||||
|
||||
class Version2003Date20241021095629 extends SimpleMigrationStep {
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly IAppConfig $appConfig,
|
||||
) {
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||
$maxChunkSize = Server::get(IConfig::class)->getAppValue('files', 'max_chunk_size');
|
||||
if ($maxChunkSize === '') {
|
||||
$maxChunkSize = $this->appConfig->getValueInt('files', 'max_chunk_size');
|
||||
if ($maxChunkSize === 0) {
|
||||
// Skip if no value was configured before
|
||||
return;
|
||||
}
|
||||
|
||||
ChunkedUploadConfig::setMaxChunkSize((int)$maxChunkSize);
|
||||
Server::get(IConfig::class)->deleteAppValue('files', 'max_chunk_size');
|
||||
ChunkedUploadConfig::setMaxChunkSize($maxChunkSize);
|
||||
$this->appConfig->deleteKey('files', 'max_chunk_size');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@ namespace OCA\Files_External\Migration;
|
|||
|
||||
use Closure;
|
||||
use OCA\Files_External\Service\GlobalStoragesService;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
/**
|
||||
* Check for any external storage overwriting the home folder
|
||||
|
|
@ -22,13 +21,10 @@ use OCP\Migration\SimpleMigrationStep;
|
|||
class Version1025Date20250228162604 extends SimpleMigrationStep {
|
||||
public function __construct(
|
||||
private GlobalStoragesService $globalStoragesServices,
|
||||
private IAppConfig $appConfig,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
*/
|
||||
#[Override]
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||
$this->globalStoragesServices->updateOverwriteHomeFolders();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,13 @@ use OCP\Migration\Attributes\AddColumn;
|
|||
use OCP\Migration\Attributes\ColumnType;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
#[AddColumn(table: 'share', name: 'reminder_sent', type: ColumnType::BOOLEAN)]
|
||||
class Version31000Date20240821142813 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
$table = $schema->getTable('share');
|
||||
if ($table->hasColumn('reminder_sent')) {
|
||||
|
|
|
|||
|
|
@ -16,13 +16,11 @@ use OCP\Migration\Attributes\AddColumn;
|
|||
use OCP\Migration\Attributes\ColumnType;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
#[AddColumn(table: 'files_trash', name: 'deleted_by', type: ColumnType::STRING)]
|
||||
class Version1020Date20240403003535 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
|||
|
|
@ -15,11 +15,10 @@ use OCP\DB\ISchemaWrapper;
|
|||
use OCP\DB\Types;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
class Version1000Date20240527153425 extends SimpleMigrationStep {
|
||||
/**
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
|||
|
|
@ -14,16 +14,12 @@ use OCA\WebhookListeners\Db\WebhookListenerMapper;
|
|||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
class Version1001Date20240716184935 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
if ($schema->hasTable(WebhookListenerMapper::TABLE_NAME)) {
|
||||
|
|
|
|||
|
|
@ -16,15 +16,10 @@ use OCP\DB\ISchemaWrapper;
|
|||
use OCP\DB\Types;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
class Version1500Date20251007130000 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
$schema = $schemaClosure();
|
||||
$schemaHasChanged = false;
|
||||
|
|
|
|||
|
|
@ -1318,12 +1318,6 @@
|
|||
<code><![CDATA[$i]]></code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="apps/files/lib/Migration/Version2003Date20241021095629.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[deleteAppValue]]></code>
|
||||
<code><![CDATA[getAppValue]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="apps/files/lib/Service/OwnershipTransferService.php">
|
||||
<DeprecatedClass>
|
||||
<code><![CDATA[\OC_Util::setupFS($destinationUser->getUID())]]></code>
|
||||
|
|
@ -3535,7 +3529,6 @@
|
|||
<file src="lib/private/Files/Cache/Wrapper/CacheWrapper.php">
|
||||
<LessSpecificImplementedReturnType>
|
||||
<code><![CDATA[array]]></code>
|
||||
<code><![CDATA[array]]></code>
|
||||
</LessSpecificImplementedReturnType>
|
||||
</file>
|
||||
<file src="lib/private/Files/Config/MountProviderCollection.php">
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use OC\DB\Connection;
|
|||
use OC\DB\MigrationService;
|
||||
use OC\DB\SchemaWrapper;
|
||||
use OC\Migration\NullOutput;
|
||||
use Override;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
|
@ -21,11 +22,12 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
|
||||
class ExpectedSchema extends Base {
|
||||
public function __construct(
|
||||
protected Connection $connection,
|
||||
protected readonly Connection $connection,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
#[Override]
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('db:schema:expected')
|
||||
|
|
@ -36,6 +38,7 @@ class ExpectedSchema extends Base {
|
|||
parent::configure();
|
||||
}
|
||||
|
||||
#[Override]
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
$schema = new Schema();
|
||||
$onlyTable = $input->getArgument('table');
|
||||
|
|
|
|||
|
|
@ -14,14 +14,10 @@ use OCP\DB\ISchemaWrapper;
|
|||
use OCP\DB\Types;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
class Version29000Date20231213104850 extends SimpleMigrationStep {
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
|||
|
|
@ -11,18 +11,14 @@ use Closure;
|
|||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Version29000Date20240131122720 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
|||
|
|
@ -14,16 +14,12 @@ use OCP\DB\ISchemaWrapper;
|
|||
use OCP\Migration\Attributes\ModifyColumn;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
#[ModifyColumn(table: 'taskprocessing_tasks', name: 'error_message', description: 'Increase column length to 4000 bytes to support longer error messages')]
|
||||
class Version30000Date20240906095113 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ declare(strict_types=1);
|
|||
namespace OC\Core\Migrations;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\Attributes\DataCleansing;
|
||||
use OCP\Migration\IOutput;
|
||||
|
|
@ -26,15 +25,10 @@ use Override;
|
|||
#[DataCleansing(table: 'vcategory_to_object', description: 'Update object references')]
|
||||
class Version32000Date20250731062008 extends SimpleMigrationStep {
|
||||
public function __construct(
|
||||
private IDBConnection $connection,
|
||||
private readonly IDBConnection $connection,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
*/
|
||||
#[Override]
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||
// Clean up duplicate categories before adding unique constraint
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use OCP\DB\Types;
|
|||
use OCP\Migration\Attributes\CreateTable;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -22,9 +23,7 @@ use OCP\Migration\SimpleMigrationStep;
|
|||
#[CreateTable(table: 'preview_locations', description: 'Holds the preview location in an object store')]
|
||||
class Version33000Date20250819110529 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use OCP\DB\ISchemaWrapper;
|
|||
use OCP\Migration\Attributes\ModifyColumn;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use Override;
|
||||
|
||||
/**
|
||||
* Migrate away from auto-increment
|
||||
|
|
@ -21,9 +22,7 @@ use OCP\Migration\SimpleMigrationStep;
|
|||
#[ModifyColumn(table: 'previews', name: 'id', description: 'Remove auto-increment')]
|
||||
#[ModifyColumn(table: 'preview_versions', name: 'id', description: 'Remove auto-increment')]
|
||||
class Version33000Date20251023110529 extends SimpleMigrationStep {
|
||||
/**
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
$schema = $schemaClosure();
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ class Version33000Date20251023120529 extends SimpleMigrationStep {
|
|||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
*/
|
||||
#[\Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
@ -41,6 +39,7 @@ class Version33000Date20251023120529 extends SimpleMigrationStep {
|
|||
return $schema;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
// This shouldn't run on a production instance, only daily
|
||||
$qb = $this->connection->getQueryBuilder();
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@ use Override;
|
|||
|
||||
#[ModifyColumn(table: 'jobs', name: 'id', description: 'Remove auto-increment')]
|
||||
class Version33000Date20251124110529 extends SimpleMigrationStep {
|
||||
/**
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
|||
|
|
@ -11,13 +11,20 @@ use Closure;
|
|||
use OCP\DB\ISchemaWrapper;
|
||||
|
||||
/**
|
||||
* This interface represents a database migration step.
|
||||
*
|
||||
* To implement a migration step, you must extend \OCP\Migration\SimpleMigrationStep
|
||||
*
|
||||
* You should additionally add some attributes found in the
|
||||
* \OCP\Migration\Attributes namespace to the migration, to describe the change
|
||||
* that will be done by the migration step to the admin.
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
interface IMigrationStep {
|
||||
/**
|
||||
* Human-readable name of the migration step
|
||||
*
|
||||
* @return string
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function name(): string;
|
||||
|
|
@ -25,35 +32,28 @@ interface IMigrationStep {
|
|||
/**
|
||||
* Human-readable description of the migration step
|
||||
*
|
||||
* @return string
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function description(): string;
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @psalm-param Closure():ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @param Closure():ISchemaWrapper $schemaClosure
|
||||
* @param array{tablePrefix?: string} $options
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options);
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @psalm-param Closure():ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @param Closure():ISchemaWrapper $schemaClosure
|
||||
* @param array{tablePrefix?: string} $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options);
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @psalm-param Closure():ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @param Closure():ISchemaWrapper $schemaClosure
|
||||
* @param array{tablePrefix?: string} $options
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options);
|
||||
|
|
|
|||
|
|
@ -7,62 +7,34 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace OCP\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use Override;
|
||||
|
||||
/**
|
||||
* Abstract class implementing migration step.
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
abstract class SimpleMigrationStep implements IMigrationStep {
|
||||
/**
|
||||
* Human-readable name of the migration step
|
||||
*
|
||||
* @return string
|
||||
* @since 14.0.0
|
||||
*/
|
||||
#[Override]
|
||||
public function name(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Human-readable description of the migration step
|
||||
*
|
||||
* @return string
|
||||
* @since 14.0.0
|
||||
*/
|
||||
#[Override]
|
||||
public function description(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @psalm-param Closure():ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @since 13.0.0
|
||||
*/
|
||||
#[Override]
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @psalm-param Closure():ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @since 13.0.0
|
||||
*/
|
||||
#[Override]
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @psalm-param Closure():ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @since 13.0.0
|
||||
*/
|
||||
#[Override]
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue