<?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 Version20260717073617 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Add appointment_events table (appointment Timeline / audit events)';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('CREATE TABLE appointment_events (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, type VARCHAR(40) NOT NULL, title VARCHAR(191) NOT NULL, actor_user_id INT DEFAULT NULL, actor_name VARCHAR(191) DEFAULT NULL, reason LONGTEXT DEFAULT NULL, created_at INT NOT NULL, appointment_id INT NOT NULL, UNIQUE INDEX UNIQ_14D9E804D17F50A6 (uuid), INDEX IDX_14D9E804E5B533F9 (appointment_id), INDEX idx_appointment_events_appt (appointment_id, created_at), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('ALTER TABLE appointment_events ADD CONSTRAINT FK_14D9E804E5B533F9 FOREIGN KEY (appointment_id) REFERENCES appointments (id) ON DELETE CASCADE');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE appointment_events DROP FOREIGN KEY FK_14D9E804E5B533F9');
        $this->addSql('DROP TABLE appointment_events');
    }
}
