migrations/Version20231108070950.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20231108070950 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE education_materials_fields (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, datatype VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
  19.         $this->addSql('CREATE TABLE education_materials_type (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
  20.         $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))');
  21.         $this->addSql('CREATE INDEX IDX_14C4A28C81472325 ON education_materials_type_education_materials_fields (education_materials_type_id)');
  22.         $this->addSql('CREATE INDEX IDX_14C4A28CD8A2CAE2 ON education_materials_type_education_materials_fields (education_materials_fields_id)');
  23.         $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))');
  24.         $this->addSql('CREATE INDEX IDX_3525898A443707B0 ON education_materials_values (field_id)');
  25.         $this->addSql('CREATE INDEX IDX_3525898A32C8A3DE ON education_materials_values (organization_id)');
  26.         $this->addSql('CREATE INDEX IDX_3525898AC54C8C93 ON education_materials_values (type_id)');
  27.         $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');
  28.         $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');
  29.         $this->addSql('ALTER TABLE education_materials_values ADD CONSTRAINT FK_3525898A443707B0 FOREIGN KEY (field_id) REFERENCES education_materials_fields (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  30.         $this->addSql('ALTER TABLE education_materials_values ADD CONSTRAINT FK_3525898A32C8A3DE FOREIGN KEY (organization_id) REFERENCES organization (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  31.         $this->addSql('ALTER TABLE education_materials_values ADD CONSTRAINT FK_3525898AC54C8C93 FOREIGN KEY (type_id) REFERENCES education_materials_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  32.     }
  33.     public function down(Schema $schema): void
  34.     {
  35.         // this down() migration is auto-generated, please modify it to your needs
  36.         $this->addSql('CREATE SCHEMA public');
  37.         $this->addSql('ALTER TABLE education_materials_type_education_materials_fields DROP CONSTRAINT FK_14C4A28C81472325');
  38.         $this->addSql('ALTER TABLE education_materials_type_education_materials_fields DROP CONSTRAINT FK_14C4A28CD8A2CAE2');
  39.         $this->addSql('ALTER TABLE education_materials_values DROP CONSTRAINT FK_3525898A443707B0');
  40.         $this->addSql('ALTER TABLE education_materials_values DROP CONSTRAINT FK_3525898A32C8A3DE');
  41.         $this->addSql('ALTER TABLE education_materials_values DROP CONSTRAINT FK_3525898AC54C8C93');
  42.         $this->addSql('DROP TABLE education_materials_fields');
  43.         $this->addSql('DROP TABLE education_materials_type');
  44.         $this->addSql('DROP TABLE education_materials_type_education_materials_fields');
  45.         $this->addSql('DROP TABLE education_materials_values');
  46.     }
  47. }