mirror of
https://github.com/crowetic/nc-talk-ai.git
synced 2026-09-07 15:42:31 +00:00
Talk AI is a multi-bot AI assistant manager for Nextcloud Talk: per-bot prompts and models, agentic tool calling (MCP + built-in tools), RAG over Nextcloud files, room-document search, vision and speech-to-text attachments, persistent bot wikis, approval workflows, rate limiting, and multi-provider LLM support (any OpenAI-compatible endpoint). Developed within EDUC - the European Digital UniverCity (https://educalliance.eu), where it runs as the 'EDUC AI' assistant on the alliance-wide Nextcloud portal. This public repository is the upstream point of truth; deployment-specific tools plug in via the tool-provider extension point (docs/TOOL_PROVIDERS.md). License: AGPL-3.0-or-later.
111 lines
3.4 KiB
PHP
111 lines
3.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\EducAI\Migration;
|
|
|
|
use Closure;
|
|
use OCP\DB\ISchemaWrapper;
|
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
|
use OCP\DB\Types;
|
|
use OCP\IDBConnection;
|
|
use OCP\Migration\IOutput;
|
|
use OCP\Migration\SimpleMigrationStep;
|
|
|
|
/**
|
|
* Ensure app icon configuration columns exist on instances that already ran
|
|
* the earlier 023702 migration before those columns were introduced.
|
|
*/
|
|
class Version023801Date20260618120000 extends SimpleMigrationStep {
|
|
public function __construct(
|
|
private IDBConnection $connection,
|
|
) {}
|
|
|
|
/**
|
|
* @param IOutput $output
|
|
* @param Closure(): ISchemaWrapper $schemaClosure
|
|
* @param array<string,mixed> $options
|
|
*/
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
|
/** @var ISchemaWrapper $schema */
|
|
$schema = $schemaClosure();
|
|
|
|
if (!$schema->hasTable('educai_settings')) {
|
|
return $schema;
|
|
}
|
|
|
|
$table = $schema->getTable('educai_settings');
|
|
if (!$table->hasColumn('app_icon_url')) {
|
|
$table->addColumn('app_icon_url', Types::TEXT, [
|
|
'notnull' => false,
|
|
]);
|
|
}
|
|
if (!$table->hasColumn('app_icon_mode')) {
|
|
$table->addColumn('app_icon_mode', Types::STRING, [
|
|
'notnull' => true,
|
|
'length' => 32,
|
|
'default' => 'default',
|
|
]);
|
|
}
|
|
if (!$table->hasColumn('app_icon_preset')) {
|
|
$table->addColumn('app_icon_preset', Types::STRING, [
|
|
'notnull' => false,
|
|
'length' => 128,
|
|
]);
|
|
}
|
|
if (!$table->hasColumn('app_icon_black_url')) {
|
|
$table->addColumn('app_icon_black_url', Types::TEXT, [
|
|
'notnull' => false,
|
|
]);
|
|
}
|
|
if (!$table->hasColumn('app_icon_white_url')) {
|
|
$table->addColumn('app_icon_white_url', Types::TEXT, [
|
|
'notnull' => false,
|
|
]);
|
|
}
|
|
|
|
return $schema;
|
|
}
|
|
|
|
/**
|
|
* @param IOutput $output
|
|
* @param Closure(): ISchemaWrapper $schemaClosure
|
|
* @param array<string,mixed> $options
|
|
*/
|
|
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
|
/** @var ISchemaWrapper $schema */
|
|
$schema = $schemaClosure();
|
|
if (!$schema->hasTable('educai_settings')) {
|
|
return;
|
|
}
|
|
|
|
$select = $this->connection->getQueryBuilder();
|
|
$result = $select->select('id', 'app_icon_url', 'app_icon_black_url', 'app_icon_white_url')
|
|
->from('educai_settings')
|
|
->where($select->expr()->isNotNull('app_icon_url'))
|
|
->andWhere($select->expr()->neq('app_icon_url', $select->createNamedParameter('', IQueryBuilder::PARAM_STR)))
|
|
->executeQuery();
|
|
|
|
$updatedLegacyRows = 0;
|
|
while (($row = $result->fetch()) !== false) {
|
|
$legacyIconUrl = (string)$row['app_icon_url'];
|
|
if ($legacyIconUrl === '' || (string)($row['app_icon_black_url'] ?? '') !== '' || (string)($row['app_icon_white_url'] ?? '') !== '') {
|
|
continue;
|
|
}
|
|
|
|
$update = $this->connection->getQueryBuilder();
|
|
$updatedLegacyRows += $update->update('educai_settings')
|
|
->set('app_icon_mode', $update->createNamedParameter('custom'))
|
|
->set('app_icon_black_url', $update->createNamedParameter($legacyIconUrl, IQueryBuilder::PARAM_STR))
|
|
->set('app_icon_white_url', $update->createNamedParameter($legacyIconUrl, IQueryBuilder::PARAM_STR))
|
|
->where($update->expr()->eq('id', $update->createNamedParameter((int)$row['id'], IQueryBuilder::PARAM_INT)))
|
|
->executeStatement();
|
|
}
|
|
$result->closeCursor();
|
|
|
|
if ($updatedLegacyRows > 0) {
|
|
$output->info("Backfilled custom app icon variants for {$updatedLegacyRows} settings row(s).");
|
|
}
|
|
}
|
|
}
|