<?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 Version20250303144554 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 (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, identifier VARCHAR(255) NOT NULL, `order` INT UNSIGNED NOT NULL, mandatory TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_3BAE0AA75E237E06 (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE user_trip_event (id INT AUTO_INCREMENT NOT NULL, user_trip_id INT NOT NULL, event_id INT NOT NULL, date DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_46824C08FDB13004 (user_trip_id), INDEX IDX_46824C0871F7E88B (event_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE user_trip_event ADD CONSTRAINT FK_46824C08FDB13004 FOREIGN KEY (user_trip_id) REFERENCES user_trip (id)');
        $this->addSql('ALTER TABLE user_trip_event ADD CONSTRAINT FK_46824C0871F7E88B FOREIGN KEY (event_id) REFERENCES event (id)');
        $this->addSql('ALTER TABLE user_trip_location DROP FOREIGN KEY FK_1841178B64D218E');
        $this->addSql('ALTER TABLE user_trip_location DROP FOREIGN KEY FK_1841178BFDB13004');
        $this->addSql('ALTER TABLE user_trip_work_log DROP FOREIGN KEY FK_B38EA119FDB13004');
        $this->addSql('ALTER TABLE user_trip_work_log DROP FOREIGN KEY FK_B38EA1195C3A313A');
        $this->addSql('ALTER TABLE user_trip_work_log DROP FOREIGN KEY FK_B38EA119C43C7F1');
        $this->addSql('DROP TABLE user_trip_location');
        $this->addSql('DROP TABLE user_trip_work_log');
        $this->addSql('ALTER TABLE trip_location ADD is_arrival TINYINT(1) NOT NULL');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE user_trip_location (id INT AUTO_INCREMENT NOT NULL, user_trip_id INT NOT NULL, location_id INT NOT NULL, planned_date DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_1841178BFDB13004 (user_trip_id), INDEX IDX_1841178B64D218E (location_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
        $this->addSql('CREATE TABLE user_trip_work_log (id INT AUTO_INCREMENT NOT NULL, user_trip_id INT NOT NULL, start_location_id INT NOT NULL, end_location_id INT NOT NULL, start_date DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', end_date DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_B38EA119C43C7F1 (end_location_id), INDEX IDX_B38EA119FDB13004 (user_trip_id), INDEX IDX_B38EA1195C3A313A (start_location_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
        $this->addSql('ALTER TABLE user_trip_location ADD CONSTRAINT FK_1841178B64D218E FOREIGN KEY (location_id) REFERENCES location (id)');
        $this->addSql('ALTER TABLE user_trip_location ADD CONSTRAINT FK_1841178BFDB13004 FOREIGN KEY (user_trip_id) REFERENCES user_trip (id)');
        $this->addSql('ALTER TABLE user_trip_work_log ADD CONSTRAINT FK_B38EA119FDB13004 FOREIGN KEY (user_trip_id) REFERENCES user_trip (id)');
        $this->addSql('ALTER TABLE user_trip_work_log ADD CONSTRAINT FK_B38EA1195C3A313A FOREIGN KEY (start_location_id) REFERENCES location (id)');
        $this->addSql('ALTER TABLE user_trip_work_log ADD CONSTRAINT FK_B38EA119C43C7F1 FOREIGN KEY (end_location_id) REFERENCES location (id)');
        $this->addSql('ALTER TABLE user_trip_event DROP FOREIGN KEY FK_46824C08FDB13004');
        $this->addSql('ALTER TABLE user_trip_event DROP FOREIGN KEY FK_46824C0871F7E88B');
        $this->addSql('DROP TABLE event');
        $this->addSql('DROP TABLE user_trip_event');
        $this->addSql('ALTER TABLE trip_location DROP is_arrival');
    }
}
