<?php

declare(strict_types=1);

namespace OCA\Mitgliederverwaltung\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
 * Add optional 'uhrzeit' (time) column to mv_injuries.
 */
class Version000017Date20260411000000 extends SimpleMigrationStep {

    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
        /** @var ISchemaWrapper $schema */
        $schema = $schemaClosure();

        $table = $schema->getTable('mv_injuries');

        if (!$table->hasColumn('uhrzeit')) {
            $table->addColumn('uhrzeit', 'string', [
                'notnull' => false,
                'length' => 5,
                'default' => null,
            ]);
        }

        return $schema;
    }
}
