<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20260224143000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Create student_import_batches table for CSV/XLSX student import wizard';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('CREATE TABLE student_import_batches (
            id UUID NOT NULL,
            tenant_id UUID NOT NULL,
            original_filename VARCHAR(255) NOT NULL,
            total_rows INT NOT NULL DEFAULT 0,
            detected_columns JSONB NOT NULL DEFAULT \'[]\',
            detected_format VARCHAR(50) DEFAULT NULL,
            status VARCHAR(20) NOT NULL DEFAULT \'pending\',
            mapping_data JSONB DEFAULT NULL,
            imported_count INT NOT NULL DEFAULT 0,
            error_count INT NOT NULL DEFAULT 0,
            rows_data JSONB NOT NULL DEFAULT \'[]\',
            created_at TIMESTAMPTZ NOT NULL,
            completed_at TIMESTAMPTZ DEFAULT NULL,
            PRIMARY KEY (id)
        )');

        $this->addSql('CREATE INDEX idx_student_import_batches_tenant ON student_import_batches (tenant_id)');
        $this->addSql('CREATE INDEX idx_student_import_batches_status ON student_import_batches (status)');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('DROP TABLE student_import_batches');
    }
}
