<?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 Version20191121142653 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 external_user (id INT AUTO_INCREMENT NOT NULL, company_supplier_id INT DEFAULT NULL, type_id INT NOT NULL, status_id INT NOT NULL, name VARCHAR(255) NOT NULL, surname VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, is_privacy_confirmed TINYINT(1) NOT NULL, INDEX IDX_188CB665330CD514 (company_supplier_id), INDEX IDX_188CB665C54C8C93 (type_id), INDEX IDX_188CB6656BF700BD (status_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE external_user ADD CONSTRAINT FK_188CB665330CD514 FOREIGN KEY (company_supplier_id) REFERENCES company_supplier (id)');
$this->addSql('ALTER TABLE external_user ADD CONSTRAINT FK_188CB665C54C8C93 FOREIGN KEY (type_id) REFERENCES user_type (id)');
$this->addSql('ALTER TABLE external_user ADD CONSTRAINT FK_188CB6656BF700BD FOREIGN KEY (status_id) REFERENCES user_status (id)');
$this->addSql('DROP TABLE utilities');
$this->addSql('ALTER TABLE access DROP FOREIGN KEY FK_6692B54A76ED395');
$this->addSql('ALTER TABLE access CHANGE user_id user_id INT DEFAULT NULL, CHANGE reference_person_id reference_person_id INT DEFAULT NULL, CHANGE release_date release_date DATETIME DEFAULT NULL');
$this->addSql('ALTER TABLE access ADD CONSTRAINT FK_6692B54A76ED395 FOREIGN KEY (user_id) REFERENCES external_user (id)');
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D649330CD514');
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D6496BF700BD');
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D649C54C8C93');
$this->addSql('DROP INDEX IDX_8D93D6496BF700BD ON user');
$this->addSql('DROP INDEX IDX_8D93D649C54C8C93 ON user');
$this->addSql('DROP INDEX IDX_8D93D649330CD514 ON user');
$this->addSql('ALTER TABLE user ADD uuid VARCHAR(180) NOT NULL, ADD roles JSON NOT NULL, ADD password VARCHAR(255) NOT NULL, DROP company_supplier_id, DROP type_id, DROP status_id, DROP name, DROP surname, DROP created_at, DROP updated_at, DROP is_privacy_confirmed');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649D17F50A6 ON user (uuid)');
}
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_6692B54A76ED395');
$this->addSql('CREATE TABLE utilities (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(180) NOT NULL COLLATE utf8mb4_unicode_ci, roles LONGTEXT NOT NULL COLLATE utf8mb4_bin, password VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci, UNIQUE INDEX UNIQ_F3C0A675D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('DROP TABLE external_user');
$this->addSql('ALTER TABLE access DROP FOREIGN KEY FK_6692B54A76ED395');
$this->addSql('ALTER TABLE access CHANGE user_id user_id INT DEFAULT NULL, CHANGE reference_person_id reference_person_id INT DEFAULT NULL, CHANGE release_date release_date DATETIME DEFAULT \'NULL\'');
$this->addSql('ALTER TABLE access ADD CONSTRAINT FK_6692B54A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('DROP INDEX UNIQ_8D93D649D17F50A6 ON user');
$this->addSql('ALTER TABLE user ADD company_supplier_id INT DEFAULT NULL, ADD type_id INT NOT NULL, ADD status_id INT NOT NULL, ADD surname VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci, ADD created_at DATETIME NOT NULL, ADD updated_at DATETIME NOT NULL, ADD is_privacy_confirmed TINYINT(1) NOT NULL, DROP uuid, DROP roles, CHANGE password name VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D649330CD514 FOREIGN KEY (company_supplier_id) REFERENCES company_supplier (id)');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D6496BF700BD FOREIGN KEY (status_id) REFERENCES user_status (id)');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D649C54C8C93 FOREIGN KEY (type_id) REFERENCES user_type (id)');
$this->addSql('CREATE INDEX IDX_8D93D6496BF700BD ON user (status_id)');
$this->addSql('CREATE INDEX IDX_8D93D649C54C8C93 ON user (type_id)');
$this->addSql('CREATE INDEX IDX_8D93D649330CD514 ON user (company_supplier_id)');
}
}