<?php

/**
 * FRAM-1099
 * 
 * This merge request adds a new table: `indexing_vector_cache`.
 * 
 * This new table is responsible for storing cached vector embeddings to reduce the amount of calls
 * made to the AI API server.
 */

use Claromentis\Core\DAL;

/** @var \Claromentis\Setup\SetupFacade $migrations */
$logger = $migrations->getLogger();

$logger->notice("Starting migration for FRAM-1104");

$database = $migrations->GetDb();

try {
    $database->AlterColumn('ai_chat_history', 'value', 'value', "CLOB NULL");
} catch (DAL\Exceptions\TransactionException $exception) {
    $logger->error("Migration failed for FRAM-1104");

    // Rethrow the exception to ensure the migration and upgrade fails
    throw $exception;
}