<?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 Version20231108070950 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 education_materials_fields (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, datatype VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE education_materials_type (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE education_materials_type_education_materials_fields (education_materials_type_id INT NOT NULL, education_materials_fields_id INT NOT NULL, PRIMARY KEY(education_materials_type_id, education_materials_fields_id))');
$this->addSql('CREATE INDEX IDX_14C4A28C81472325 ON education_materials_type_education_materials_fields (education_materials_type_id)');
$this->addSql('CREATE INDEX IDX_14C4A28CD8A2CAE2 ON education_materials_type_education_materials_fields (education_materials_fields_id)');
$this->addSql('CREATE TABLE education_materials_values (id SERIAL NOT NULL, field_id INT NOT NULL, organization_id INT NOT NULL, type_id INT NOT NULL, value TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_3525898A443707B0 ON education_materials_values (field_id)');
$this->addSql('CREATE INDEX IDX_3525898A32C8A3DE ON education_materials_values (organization_id)');
$this->addSql('CREATE INDEX IDX_3525898AC54C8C93 ON education_materials_values (type_id)');
$this->addSql('ALTER TABLE education_materials_type_education_materials_fields ADD CONSTRAINT FK_14C4A28C81472325 FOREIGN KEY (education_materials_type_id) REFERENCES education_materials_type (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE education_materials_type_education_materials_fields ADD CONSTRAINT FK_14C4A28CD8A2CAE2 FOREIGN KEY (education_materials_fields_id) REFERENCES education_materials_fields (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE education_materials_values ADD CONSTRAINT FK_3525898A443707B0 FOREIGN KEY (field_id) REFERENCES education_materials_fields (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE education_materials_values ADD CONSTRAINT FK_3525898A32C8A3DE FOREIGN KEY (organization_id) REFERENCES organization (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE education_materials_values ADD CONSTRAINT FK_3525898AC54C8C93 FOREIGN KEY (type_id) REFERENCES education_materials_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE education_materials_type_education_materials_fields DROP CONSTRAINT FK_14C4A28C81472325');
$this->addSql('ALTER TABLE education_materials_type_education_materials_fields DROP CONSTRAINT FK_14C4A28CD8A2CAE2');
$this->addSql('ALTER TABLE education_materials_values DROP CONSTRAINT FK_3525898A443707B0');
$this->addSql('ALTER TABLE education_materials_values DROP CONSTRAINT FK_3525898A32C8A3DE');
$this->addSql('ALTER TABLE education_materials_values DROP CONSTRAINT FK_3525898AC54C8C93');
$this->addSql('DROP TABLE education_materials_fields');
$this->addSql('DROP TABLE education_materials_type');
$this->addSql('DROP TABLE education_materials_type_education_materials_fields');
$this->addSql('DROP TABLE education_materials_values');
}
}