<?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 Version20241205122341 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 training_question (training_id INT NOT NULL, question_id INT NOT NULL, INDEX IDX_51925AD9BEFD98D1 (training_id), INDEX IDX_51925AD91E27F6BF (question_id), PRIMARY KEY(training_id, question_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE training_question ADD CONSTRAINT FK_51925AD9BEFD98D1 FOREIGN KEY (training_id) REFERENCES training (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE training_question ADD CONSTRAINT FK_51925AD91E27F6BF FOREIGN KEY (question_id) REFERENCES question (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE training DROP FOREIGN KEY FK_D5128A8F1E27F6BF');
$this->addSql('DROP INDEX IDX_D5128A8F1E27F6BF ON training');
$this->addSql('ALTER TABLE training DROP question_id');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE training_question DROP FOREIGN KEY FK_51925AD9BEFD98D1');
$this->addSql('ALTER TABLE training_question DROP FOREIGN KEY FK_51925AD91E27F6BF');
$this->addSql('DROP TABLE training_question');
$this->addSql('ALTER TABLE training ADD question_id INT NOT NULL');
$this->addSql('ALTER TABLE training ADD CONSTRAINT FK_D5128A8F1E27F6BF FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
$this->addSql('CREATE INDEX IDX_D5128A8F1E27F6BF ON training (question_id)');
}
}