<?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 Version20260716102537 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Session wizard parity: session_consumables table, patient_sessions.session_at and inventory_package_id';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE session_consumables (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, price_rials INT NOT NULL, quantity INT NOT NULL, created_at INT NOT NULL, session_id INT NOT NULL, inventory_item_id INT NOT NULL, UNIQUE INDEX UNIQ_6776C347D17F50A6 (uuid), INDEX IDX_6776C347613FECDF (session_id), INDEX IDX_6776C347536BF4A2 (inventory_item_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('ALTER TABLE session_consumables ADD CONSTRAINT FK_6776C347613FECDF FOREIGN KEY (session_id) REFERENCES patient_sessions (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE session_consumables ADD CONSTRAINT FK_6776C347536BF4A2 FOREIGN KEY (inventory_item_id) REFERENCES inventory_items (id) ON DELETE RESTRICT');
        $this->addSql('ALTER TABLE patient_sessions ADD session_at INT DEFAULT NULL, ADD inventory_package_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE patient_sessions ADD CONSTRAINT FK_ADE5C5B6B7A2FE7C FOREIGN KEY (inventory_package_id) REFERENCES inventory_packages (id) ON DELETE SET NULL');
        $this->addSql('CREATE INDEX IDX_ADE5C5B6B7A2FE7C ON patient_sessions (inventory_package_id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE session_consumables DROP FOREIGN KEY FK_6776C347613FECDF');
        $this->addSql('ALTER TABLE session_consumables DROP FOREIGN KEY FK_6776C347536BF4A2');
        $this->addSql('DROP TABLE session_consumables');
        $this->addSql('ALTER TABLE patient_sessions DROP FOREIGN KEY FK_ADE5C5B6B7A2FE7C');
        $this->addSql('DROP INDEX IDX_ADE5C5B6B7A2FE7C ON patient_sessions');
        $this->addSql('ALTER TABLE patient_sessions DROP session_at, DROP inventory_package_id');
    }
}
