api/src/Migrations/Version20210601082339.php
<?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 Version20210601082339 extends AbstractMigration
{
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 language (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE source (id INT AUTO_INCREMENT NOT NULL, domain VARCHAR(45) NOT NULL, property VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE translate (id INT AUTO_INCREMENT NOT NULL, language_id INT NOT NULL, source_id INT NOT NULL, text VARCHAR(255) NOT NULL, INDEX IDX_4A10637782F1BAF4 (language_id), INDEX IDX_4A106377953C1C61 (source_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE translate ADD CONSTRAINT FK_4A10637782F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id)');
$this->addSql('ALTER TABLE translate ADD CONSTRAINT FK_4A106377953C1C61 FOREIGN KEY (source_id) REFERENCES source (id)');
$this->addSql('ALTER TABLE user ADD language_id INT DEFAULT NULL, DROP language');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D64982F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id)');
$this->addSql('CREATE INDEX IDX_8D93D64982F1BAF4 ON user (language_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 translate DROP FOREIGN KEY FK_4A10637782F1BAF4');
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D64982F1BAF4');
$this->addSql('ALTER TABLE translate DROP FOREIGN KEY FK_4A106377953C1C61');
$this->addSql('DROP TABLE language');
$this->addSql('DROP TABLE source');
$this->addSql('DROP TABLE translate');
$this->addSql('DROP INDEX IDX_8D93D64982F1BAF4 ON user');
$this->addSql('ALTER TABLE user ADD language VARCHAR(10) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, DROP language_id');
}
}