<?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 Version20210723124028 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 agent (id INT AUTO_INCREMENT NOT NULL, type_agent_id INT NOT NULL, responsable_id INT DEFAULT NULL, code_agent VARCHAR(10) NOT NULL, nom_agent VARCHAR(255) NOT NULL, INDEX IDX_268B9C9DF9EB56F7 (type_agent_id), INDEX IDX_268B9C9D53C59D72 (responsable_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE type_agent (id INT AUTO_INCREMENT NOT NULL, libelle VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE agent ADD CONSTRAINT FK_268B9C9DF9EB56F7 FOREIGN KEY (type_agent_id) REFERENCES type_agent (id)');
        $this->addSql('ALTER TABLE agent ADD CONSTRAINT FK_268B9C9D53C59D72 FOREIGN KEY (responsable_id) REFERENCES agent (id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE agent DROP FOREIGN KEY FK_268B9C9D53C59D72');
        $this->addSql('ALTER TABLE agent DROP FOREIGN KEY FK_268B9C9DF9EB56F7');
        $this->addSql('DROP TABLE agent');
        $this->addSql('DROP TABLE type_agent');
    }
}
