<?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 Version20220330114845 extends AbstractMigration
{
public function getDescription(): string
{
return 'création des livrets d\'apprentissage';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE livret (id INT AUTO_INCREMENT NOT NULL, intitule VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE livret_shop_categorie (livret_id INT NOT NULL, shop_categorie_id INT NOT NULL, INDEX IDX_3C4CAAA376274781 (livret_id), INDEX IDX_3C4CAAA3A19080BF (shop_categorie_id), PRIMARY KEY(livret_id, shop_categorie_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE livret_acquis (id INT AUTO_INCREMENT NOT NULL, competence_id INT NOT NULL, intitule VARCHAR(255) NOT NULL, INDEX IDX_7D3A72C515761DAB (competence_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE livret_competence (id INT AUTO_INCREMENT NOT NULL, livret_id INT NOT NULL, intitule VARCHAR(255) NOT NULL, INDEX IDX_4C07CE2076274781 (livret_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE livret_shop_categorie ADD CONSTRAINT FK_3C4CAAA376274781 FOREIGN KEY (livret_id) REFERENCES livret (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE livret_shop_categorie ADD CONSTRAINT FK_3C4CAAA3A19080BF FOREIGN KEY (shop_categorie_id) REFERENCES shop_categorie (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE livret_acquis ADD CONSTRAINT FK_7D3A72C515761DAB FOREIGN KEY (competence_id) REFERENCES livret_competence (id)');
$this->addSql('ALTER TABLE livret_competence ADD CONSTRAINT FK_4C07CE2076274781 FOREIGN KEY (livret_id) REFERENCES livret (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE livret_shop_categorie DROP FOREIGN KEY FK_3C4CAAA376274781');
$this->addSql('ALTER TABLE livret_competence DROP FOREIGN KEY FK_4C07CE2076274781');
$this->addSql('ALTER TABLE livret_acquis DROP FOREIGN KEY FK_7D3A72C515761DAB');
$this->addSql('DROP TABLE livret');
$this->addSql('DROP TABLE livret_shop_categorie');
$this->addSql('DROP TABLE livret_acquis');
$this->addSql('DROP TABLE livret_competence');
}
}