<?php

declare(strict_types=1);

namespace Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20251006214741 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Add ON DELETE actions to foreign keys';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE kampagnen DROP FOREIGN KEY `FK_37572FC6A76ED395`');
        $this->addSql('ALTER TABLE kampagnen ADD CONSTRAINT FK_37572FC6A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY `FK_B6A62B2AA76ED395`');
        $this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY `FK_B6A62B2AACE19231`');
        $this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT FK_B6A62B2AA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT FK_B6A62B2AACE19231 FOREIGN KEY (kampagne_id) REFERENCES kampagnen (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE users DROP FOREIGN KEY `FK_1483A5E948B23AFC`');
        $this->addSql('ALTER TABLE users CHANGE rolle rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\')');
        $this->addSql('ALTER TABLE users ADD CONSTRAINT FK_1483A5E948B23AFC FOREIGN KEY (werbenetzwerk_id) REFERENCES werbenetzwerk (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 kampagnen DROP FOREIGN KEY FK_37572FC6A76ED395');
        $this->addSql('ALTER TABLE kampagnen ADD CONSTRAINT `FK_37572FC6A76ED395` FOREIGN KEY (user_id) REFERENCES users (id)');
        $this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY FK_B6A62B2AACE19231');
        $this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY FK_B6A62B2AA76ED395');
        $this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT `FK_B6A62B2AACE19231` FOREIGN KEY (kampagne_id) REFERENCES kampagnen (id)');
        $this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT `FK_B6A62B2AA76ED395` FOREIGN KEY (user_id) REFERENCES users (id)');
        $this->addSql('ALTER TABLE users DROP FOREIGN KEY FK_1483A5E948B23AFC');
        $this->addSql('ALTER TABLE users CHANGE rolle rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\') DEFAULT NULL');
        $this->addSql('ALTER TABLE users ADD CONSTRAINT `FK_1483A5E948B23AFC` FOREIGN KEY (werbenetzwerk_id) REFERENCES werbenetzwerk (id)');
    }
}
