<?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 Version20260609135126 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 payments (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, order_id VARCHAR(64) NOT NULL, amount_rials INT NOT NULL, status VARCHAR(30) NOT NULL, gateway VARCHAR(20) NOT NULL, type VARCHAR(30) NOT NULL, gateway_token VARCHAR(255) DEFAULT NULL, reference_id VARCHAR(255) DEFAULT NULL, frontend_address VARCHAR(500) DEFAULT NULL, callback_ip VARCHAR(45) DEFAULT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, user_id INT NOT NULL, appointment_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_65D29B32D17F50A6 (uuid), UNIQUE INDEX UNIQ_65D29B328D9F6D38 (order_id), INDEX IDX_65D29B32E5B533F9 (appointment_id), INDEX idx_payments_order (order_id), INDEX idx_payments_user (user_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('ALTER TABLE payments ADD CONSTRAINT FK_65D29B32A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE RESTRICT');
        $this->addSql('ALTER TABLE payments ADD CONSTRAINT FK_65D29B32E5B533F9 FOREIGN KEY (appointment_id) REFERENCES appointments (id) ON DELETE SET NULL');
    }

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