<?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 Version20200212224554 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE department (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE access ADD department_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE access ADD CONSTRAINT FK_6692B54AE80F5DF FOREIGN KEY (department_id) REFERENCES department (id)');
$this->addSql('CREATE INDEX IDX_6692B54AE80F5DF ON access (department_id)');
$this->addSql('ALTER TABLE user ADD department_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D649AE80F5DF FOREIGN KEY (department_id) REFERENCES department (id)');
$this->addSql('CREATE INDEX IDX_8D93D649AE80F5DF ON user (department_id)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE access DROP FOREIGN KEY FK_6692B54AE80F5DF');
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D649AE80F5DF');
$this->addSql('DROP TABLE department');
$this->addSql('DROP INDEX IDX_6692B54AE80F5DF ON access');
$this->addSql('ALTER TABLE access DROP department_id');
$this->addSql('DROP INDEX IDX_8D93D649AE80F5DF ON user');
$this->addSql('ALTER TABLE user DROP department_id');
}
}