<?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 Version20260716063302 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Add appointment_service_items join table for multi-service appointments';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE appointment_service_items (appointment_id INT NOT NULL, service_item_id INT NOT NULL, INDEX IDX_3624BA00E5B533F9 (appointment_id), INDEX IDX_3624BA00DDEB00C2 (service_item_id), PRIMARY KEY (appointment_id, service_item_id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('ALTER TABLE appointment_service_items ADD CONSTRAINT FK_3624BA00E5B533F9 FOREIGN KEY (appointment_id) REFERENCES appointments (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE appointment_service_items ADD CONSTRAINT FK_3624BA00DDEB00C2 FOREIGN KEY (service_item_id) REFERENCES service_items (id) ON DELETE CASCADE');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE appointment_service_items DROP FOREIGN KEY FK_3624BA00E5B533F9');
        $this->addSql('ALTER TABLE appointment_service_items DROP FOREIGN KEY FK_3624BA00DDEB00C2');
        $this->addSql('DROP TABLE appointment_service_items');
    }
}
