<?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 Version20260622163152 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE entity_insurance_pricing (id INT AUTO_INCREMENT NOT NULL, entity_type VARCHAR(10) NOT NULL, entity_id INT NOT NULL, insurance_id INT DEFAULT NULL, patient_share_rials INT NOT NULL, updated_at INT NOT NULL, INDEX idx_entity_pricing_owner (entity_type, entity_id), UNIQUE INDEX uniq_entity_insurance (entity_type, entity_id, insurance_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql("INSERT INTO entity_insurance_pricing (entity_type, entity_id, insurance_id, patient_share_rials, updated_at) SELECT 'doctor', doctor_id, insurance_id, COALESCE(price, 0), UNIX_TIMESTAMP() FROM doctor_insurances WHERE price IS NOT NULL");
    }

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