Files
nuqloud-ai/lib/Migration/Version023900Date20260825000000.php

40 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\EducAI\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version023900Date20260825000000 extends SimpleMigrationStep {
/**
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array<string,mixed> $options
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
$schema = $schemaClosure();
if ($schema->hasTable('educai_tool_confirmations')) {
return $schema;
}
$table = $schema->createTable('educai_tool_confirmations');
$table->addColumn('id', Types::BIGINT, ['autoincrement' => true, 'notnull' => true, 'unsigned' => true]);
$table->addColumn('token', Types::STRING, ['notnull' => true, 'length' => 32]);
$table->addColumn('user_id', Types::STRING, ['notnull' => true, 'length' => 64]);
$table->addColumn('bot_id', Types::BIGINT, ['notnull' => false, 'unsigned' => true]);
$table->addColumn('room_token', Types::STRING, ['notnull' => false, 'length' => 64]);
$table->addColumn('tool_name', Types::STRING, ['notnull' => true, 'length' => 128]);
$table->addColumn('arguments_hash', Types::STRING, ['notnull' => true, 'length' => 64]);
$table->addColumn('expires_at', Types::BIGINT, ['notnull' => true, 'unsigned' => true]);
$table->addColumn('created_at', Types::BIGINT, ['notnull' => true, 'unsigned' => true]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['token'], 'educai_tc_token_u');
$table->addIndex(['user_id', 'expires_at'], 'educai_tc_user_exp_i');
return $schema;
}
}