Files
nextcloud-pantry/lib/Migration/Version4Date20260515000000.php

43 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: Chen Asraf <contact@casraf.dev>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\Pantry\Migration;
use Closure;
use OCA\Pantry\AppInfo\Application;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Add deleted_at timestamp to checklist items for soft deletion.
*/
class Version4Date20260515000000 extends SimpleMigrationStep {
/**
* @param Closure():ISchemaWrapper $schemaClosure
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$itemsTable = Application::tableName('list_items');
if ($schema->hasTable($itemsTable)) {
$table = $schema->getTable($itemsTable);
if (!$table->hasColumn('deleted_at')) {
$table->addColumn('deleted_at', Types::BIGINT, [
'notnull' => false,
'length' => 20,
]);
$table->addIndex(['deleted_at'], 'pantry_items_deleted_idx');
}
}
return $schema;
}
}