<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20230829203258 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('update event
                        inner join (
                            select event_date.event_id, min(event_date.date) as first_date, max(event_date.date) as last_date
                            from event_date
                            group by event_date.event_id
                        ) as event_first_last_date
                            on event.id = event_first_last_date.event_id
                        set event.first_date = event_first_last_date.first_date,
                            event.last_date = event_first_last_date.last_date');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs

    }
}
