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

41 lines
985 B
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 description column to checklist items.
*/
class Version2Date20260408000000 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('description')) {
$table->addColumn('description', Types::TEXT, [
'notnull' => false,
]);
}
}
return $schema;
}
}