Passed
Pull Request — master (#6112)
by
unknown
09:39 queued 01:20
created

Version20250305120000::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
8
9
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
10
use Doctrine\DBAL\Schema\Schema;
11
12
final class Version20250305120000 extends AbstractMigrationChamilo
13
{
14
    public function getDescription(): string
15
    {
16
        return 'Creates ai_requests table to log AI-generated requests and responses, including the AI provider used';
17
    }
18
19
    public function up(Schema $schema): void
20
    {
21
        $this->addSql('
22
            CREATE TABLE ai_requests (
23
                id INT AUTO_INCREMENT NOT NULL,
24
                user_id INT NOT NULL,
25
                tool_name VARCHAR(255) NOT NULL,
26
                requested_at DATETIME NOT NULL,
27
                request_text TEXT NOT NULL,
28
                prompt_tokens INT DEFAULT NULL,
29
                completion_tokens INT DEFAULT NULL,
30
                total_tokens INT DEFAULT NULL,
31
                ai_provider VARCHAR(50) NOT NULL,
32
                PRIMARY KEY(id)
33
            ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
34
        ');
35
    }
36
37
    public function down(Schema $schema): void
38
    {
39
        $this->addSql('DROP TABLE ai_requests;');
40
    }
41
}
42