<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

final class Version20260217231503 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Replace separate tenant/year indexes with a composite index for school_calendar_entries';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('DROP INDEX idx_calendar_tenant');
        $this->addSql('DROP INDEX idx_calendar_year');
        $this->addSql('CREATE INDEX idx_calendar_tenant_year ON school_calendar_entries(tenant_id, academic_year_id)');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('DROP INDEX idx_calendar_tenant_year');
        $this->addSql('CREATE INDEX idx_calendar_tenant ON school_calendar_entries(tenant_id)');
        $this->addSql('CREATE INDEX idx_calendar_year ON school_calendar_entries(academic_year_id)');
    }
}
