<?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 Version20221002154421 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 league (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('CREATE TABLE team (id INT AUTO_INCREMENT NOT NULL, team1 VARCHAR(255) NOT NULL, team2 VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE trip ADD league_id INT DEFAULT NULL, ADD team_id INT DEFAULT NULL, DROP league, DROP team1, DROP team2');
$this->addSql('ALTER TABLE trip ADD CONSTRAINT FK_7656F53B58AFC4DE FOREIGN KEY (league_id) REFERENCES league (id)');
$this->addSql('ALTER TABLE trip ADD CONSTRAINT FK_7656F53B296CD8AE FOREIGN KEY (team_id) REFERENCES team (id)');
$this->addSql('CREATE INDEX IDX_7656F53B58AFC4DE ON trip (league_id)');
$this->addSql('CREATE INDEX IDX_7656F53B296CD8AE ON trip (team_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE trip DROP FOREIGN KEY FK_7656F53B58AFC4DE');
$this->addSql('ALTER TABLE trip DROP FOREIGN KEY FK_7656F53B296CD8AE');
$this->addSql('DROP TABLE league');
$this->addSql('DROP TABLE team');
$this->addSql('DROP INDEX IDX_7656F53B58AFC4DE ON trip');
$this->addSql('DROP INDEX IDX_7656F53B296CD8AE ON trip');
$this->addSql('ALTER TABLE trip ADD league VARCHAR(255) NOT NULL, ADD team1 VARCHAR(255) NOT NULL, ADD team2 VARCHAR(255) NOT NULL, DROP league_id, DROP team_id');
}
}