<?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 Version20220713133751 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 trainings_user (trainings_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_4F02E972161BA2FF (trainings_id), INDEX IDX_4F02E972A76ED395 (user_id), PRIMARY KEY(trainings_id, user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE commercials_trainings (trainings_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_BD1D4C35161BA2FF (trainings_id), INDEX IDX_BD1D4C35A76ED395 (user_id), PRIMARY KEY(trainings_id, user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE trainings_user ADD CONSTRAINT FK_4F02E972161BA2FF FOREIGN KEY (trainings_id) REFERENCES trainings (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE trainings_user ADD CONSTRAINT FK_4F02E972A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE commercials_trainings ADD CONSTRAINT FK_BD1D4C35161BA2FF FOREIGN KEY (trainings_id) REFERENCES trainings (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE commercials_trainings ADD CONSTRAINT FK_BD1D4C35A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE trainings DROP FOREIGN KEY FK_66DC4330709AB3A');
$this->addSql('ALTER TABLE trainings DROP FOREIGN KEY FK_66DC43307854071C');
$this->addSql('DROP INDEX IDX_66DC4330709AB3A ON trainings');
$this->addSql('DROP INDEX IDX_66DC43307854071C ON trainings');
$this->addSql('ALTER TABLE trainings ADD is_fiche TINYINT(1) DEFAULT NULL, DROP commercial_id, CHANGE pedagogical_referent_id owner_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE trainings ADD CONSTRAINT FK_66DC43307E3C61F9 FOREIGN KEY (owner_id) REFERENCES user (id)');
$this->addSql('CREATE INDEX IDX_66DC43307E3C61F9 ON trainings (owner_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE trainings_user');
$this->addSql('DROP TABLE commercials_trainings');
$this->addSql('ALTER TABLE trainings DROP FOREIGN KEY FK_66DC43307E3C61F9');
$this->addSql('DROP INDEX IDX_66DC43307E3C61F9 ON trainings');
$this->addSql('ALTER TABLE trainings ADD commercial_id INT NOT NULL, DROP is_fiche, CHANGE owner_id pedagogical_referent_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE trainings ADD CONSTRAINT FK_66DC4330709AB3A FOREIGN KEY (pedagogical_referent_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE trainings ADD CONSTRAINT FK_66DC43307854071C FOREIGN KEY (commercial_id) REFERENCES user (id)');
$this->addSql('CREATE INDEX IDX_66DC4330709AB3A ON trainings (pedagogical_referent_id)');
$this->addSql('CREATE INDEX IDX_66DC43307854071C ON trainings (commercial_id)');
}
}