<?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 Version20220704100416 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 (id INT AUTO_INCREMENT NOT NULL, type_id INT DEFAULT NULL, certification_type_id INT DEFAULT NULL, pedagogical_referent_id INT DEFAULT NULL, commercial_id INT NOT NULL, title VARCHAR(255) NOT NULL, sub_title VARCHAR(255) DEFAULT NULL, code VARCHAR(255) DEFAULT NULL, cut_in_blocks TINYINT(1) DEFAULT NULL, new TINYINT(1) DEFAULT NULL, customizable VARCHAR(255) DEFAULT NULL, objectives LONGTEXT NOT NULL, complementary_objectives LONGTEXT DEFAULT NULL, pedagogic_content LONGTEXT NOT NULL, pluses LONGTEXT DEFAULT NULL, concerned_persons LONGTEXT NOT NULL, prerequisites LONGTEXT NOT NULL, price VARCHAR(255) DEFAULT NULL, time VARCHAR(255) NOT NULL, date VARCHAR(255) DEFAULT NULL, place VARCHAR(255) DEFAULT NULL, terms_of_access LONGTEXT DEFAULT NULL, alternating_rythm LONGTEXT DEFAULT NULL, teaching_methods LONGTEXT DEFAULT NULL, teaching_means LONGTEXT DEFAULT NULL, education_level VARCHAR(255) DEFAULT NULL, training_order INT DEFAULT NULL, certification_name VARCHAR(255) DEFAULT NULL, assessment_methods LONGTEXT DEFAULT NULL, target_functions LONGTEXT DEFAULT NULL, continuing_studies LONGTEXT DEFAULT NULL, disabled_accessibility INT DEFAULT NULL, testimonials LONGTEXT DEFAULT NULL, accessibility_text LONGTEXT DEFAULT NULL, company_missions LONGTEXT DEFAULT NULL, creation_date DATE DEFAULT NULL, qualiopi_certified TINYINT(1) DEFAULT NULL, logo_display TINYINT(1) DEFAULT NULL, is_public TINYINT(1) DEFAULT NULL, promoted TINYINT(1) DEFAULT NULL, published TINYINT(1) DEFAULT NULL, INDEX IDX_66DC4330C54C8C93 (type_id), INDEX IDX_66DC433090AF82A5 (certification_type_id), INDEX IDX_66DC4330709AB3A (pedagogical_referent_id), INDEX IDX_66DC43307854071C (commercial_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE trainings_domain (trainings_id INT NOT NULL, domain_id INT NOT NULL, INDEX IDX_2D7D1E9F161BA2FF (trainings_id), INDEX IDX_2D7D1E9F115F0EE5 (domain_id), PRIMARY KEY(trainings_id, domain_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE trainings_sub_domain (trainings_id INT NOT NULL, sub_domain_id INT NOT NULL, INDEX IDX_CFE34D91161BA2FF (trainings_id), INDEX IDX_CFE34D91352485B (sub_domain_id), PRIMARY KEY(trainings_id, sub_domain_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE trainings_keywords (trainings_id INT NOT NULL, keywords_id INT NOT NULL, INDEX IDX_BF727094161BA2FF (trainings_id), INDEX IDX_BF7270946205D0B8 (keywords_id), PRIMARY KEY(trainings_id, keywords_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE trainings_device_and_training (trainings_id INT NOT NULL, device_and_training_id INT NOT NULL, INDEX IDX_E7572806161BA2FF (trainings_id), INDEX IDX_E75728068394A420 (device_and_training_id), PRIMARY KEY(trainings_id, device_and_training_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE trainings ADD CONSTRAINT FK_66DC4330C54C8C93 FOREIGN KEY (type_id) REFERENCES type (id)');
$this->addSql('ALTER TABLE trainings ADD CONSTRAINT FK_66DC433090AF82A5 FOREIGN KEY (certification_type_id) REFERENCES certification_type (id)');
$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('ALTER TABLE trainings_domain ADD CONSTRAINT FK_2D7D1E9F161BA2FF FOREIGN KEY (trainings_id) REFERENCES trainings (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE trainings_domain ADD CONSTRAINT FK_2D7D1E9F115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE trainings_sub_domain ADD CONSTRAINT FK_CFE34D91161BA2FF FOREIGN KEY (trainings_id) REFERENCES trainings (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE trainings_sub_domain ADD CONSTRAINT FK_CFE34D91352485B FOREIGN KEY (sub_domain_id) REFERENCES sub_domain (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE trainings_keywords ADD CONSTRAINT FK_BF727094161BA2FF FOREIGN KEY (trainings_id) REFERENCES trainings (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE trainings_keywords ADD CONSTRAINT FK_BF7270946205D0B8 FOREIGN KEY (keywords_id) REFERENCES keywords (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE trainings_device_and_training ADD CONSTRAINT FK_E7572806161BA2FF FOREIGN KEY (trainings_id) REFERENCES trainings (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE trainings_device_and_training ADD CONSTRAINT FK_E75728068394A420 FOREIGN KEY (device_and_training_id) REFERENCES device_and_training (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE sessions ADD trainings_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE sessions ADD CONSTRAINT FK_9A609D13161BA2FF FOREIGN KEY (trainings_id) REFERENCES trainings (id)');
$this->addSql('CREATE INDEX IDX_9A609D13161BA2FF ON sessions (trainings_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE sessions DROP FOREIGN KEY FK_9A609D13161BA2FF');
$this->addSql('ALTER TABLE trainings_domain DROP FOREIGN KEY FK_2D7D1E9F161BA2FF');
$this->addSql('ALTER TABLE trainings_sub_domain DROP FOREIGN KEY FK_CFE34D91161BA2FF');
$this->addSql('ALTER TABLE trainings_keywords DROP FOREIGN KEY FK_BF727094161BA2FF');
$this->addSql('ALTER TABLE trainings_device_and_training DROP FOREIGN KEY FK_E7572806161BA2FF');
$this->addSql('DROP TABLE trainings');
$this->addSql('DROP TABLE trainings_domain');
$this->addSql('DROP TABLE trainings_sub_domain');
$this->addSql('DROP TABLE trainings_keywords');
$this->addSql('DROP TABLE trainings_device_and_training');
$this->addSql('DROP INDEX IDX_9A609D13161BA2FF ON sessions');
$this->addSql('ALTER TABLE sessions DROP trainings_id');
}
}