<?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 Version20260609135704 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 settlements (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, amount_rials INT NOT NULL, status VARCHAR(20) NOT NULL, bank_account JSON DEFAULT NULL, admin_note VARCHAR(500) DEFAULT NULL, reviewed_by INT DEFAULT NULL, reviewed_at INT DEFAULT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, user_id INT NOT NULL, UNIQUE INDEX UNIQ_7BF3172D17F50A6 (uuid), INDEX IDX_7BF3172A76ED395 (user_id), INDEX idx_settlements_user_status (user_id, status), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('CREATE TABLE wallet_transactions (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, amount_rials INT NOT NULL, type VARCHAR(10) NOT NULL, description VARCHAR(255) DEFAULT NULL, balance_after INT NOT NULL, created_at INT NOT NULL, user_id INT NOT NULL, payment_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_A50205E2D17F50A6 (uuid), INDEX IDX_A50205E2A76ED395 (user_id), INDEX IDX_A50205E24C3A3BB (payment_id), INDEX idx_wallet_user_date (user_id, created_at), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('ALTER TABLE settlements ADD CONSTRAINT FK_7BF3172A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE RESTRICT');
        $this->addSql('ALTER TABLE wallet_transactions ADD CONSTRAINT FK_A50205E2A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE RESTRICT');
        $this->addSql('ALTER TABLE wallet_transactions ADD CONSTRAINT FK_A50205E24C3A3BB FOREIGN KEY (payment_id) REFERENCES payments (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 settlements DROP FOREIGN KEY FK_7BF3172A76ED395');
        $this->addSql('ALTER TABLE wallet_transactions DROP FOREIGN KEY FK_A50205E2A76ED395');
        $this->addSql('ALTER TABLE wallet_transactions DROP FOREIGN KEY FK_A50205E24C3A3BB');
        $this->addSql('DROP TABLE settlements');
        $this->addSql('DROP TABLE wallet_transactions');
    }
}
