<?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 Version20240113142914 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 `evenement` (id INT AUTO_INCREMENT NOT NULL, type_id INT DEFAULT NULL, animal_id INT DEFAULT NULL, date DATETIME NOT NULL, description VARCHAR(255) DEFAULT NULL, INDEX IDX_B26681EC54C8C93 (type_id), INDEX IDX_B26681E8E962C16 (animal_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE typeevent (id INT AUTO_INCREMENT NOT NULL, nom VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE `evenement` ADD CONSTRAINT FK_B26681EC54C8C93 FOREIGN KEY (type_id) REFERENCES typeevent (id)');
        $this->addSql('ALTER TABLE `evenement` ADD CONSTRAINT FK_B26681E8E962C16 FOREIGN KEY (animal_id) REFERENCES `animal` (id)');
        $this->addSql('ALTER TABLE animal ADD user_id INT DEFAULT NULL, ADD sexe VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE animal ADD CONSTRAINT FK_6AAB231FA76ED395 FOREIGN KEY (user_id) REFERENCES `user` (id)');
        $this->addSql('CREATE INDEX IDX_6AAB231FA76ED395 ON animal (user_id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE `evenement` DROP FOREIGN KEY FK_B26681EC54C8C93');
        $this->addSql('DROP TABLE `evenement`');
        $this->addSql('DROP TABLE typeevent');
        $this->addSql('ALTER TABLE `animal` DROP FOREIGN KEY FK_6AAB231FA76ED395');
        $this->addSql('DROP INDEX IDX_6AAB231FA76ED395 ON `animal`');
        $this->addSql('ALTER TABLE `animal` DROP user_id, DROP sexe');
    }
}
