<?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 Version20230614130551 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 event_sponsor (id INT AUTO_INCREMENT NOT NULL, event_id INT NOT NULL, sponsor_id INT NOT NULL, url VARCHAR(255) NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_4DB607B71F7E88B (event_id), INDEX IDX_4DB607B12F7FB51 (sponsor_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE event_sponsor ADD CONSTRAINT FK_4DB607B71F7E88B FOREIGN KEY (event_id) REFERENCES event (id)');
        $this->addSql('ALTER TABLE event_sponsor ADD CONSTRAINT FK_4DB607B12F7FB51 FOREIGN KEY (sponsor_id) REFERENCES sponsor (id)');
        $this->addSql('ALTER TABLE event ADD main_sponsor_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE event ADD CONSTRAINT FK_3BAE0AA72A0F8F32 FOREIGN KEY (main_sponsor_id) REFERENCES sponsor (id)');
        $this->addSql('CREATE INDEX IDX_3BAE0AA72A0F8F32 ON event (main_sponsor_id)');
        $this->addSql('ALTER TABLE sponsor CHANGE type type enum(\'partner\', \'sponsor\')');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE event_sponsor DROP FOREIGN KEY FK_4DB607B71F7E88B');
        $this->addSql('ALTER TABLE event_sponsor DROP FOREIGN KEY FK_4DB607B12F7FB51');
        $this->addSql('DROP TABLE event_sponsor');
        $this->addSql('ALTER TABLE event DROP FOREIGN KEY FK_3BAE0AA72A0F8F32');
        $this->addSql('DROP INDEX IDX_3BAE0AA72A0F8F32 ON event');
        $this->addSql('ALTER TABLE event DROP main_sponsor_id');
        $this->addSql('ALTER TABLE sponsor CHANGE type type VARCHAR(255) DEFAULT NULL');
    }
}
