<?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 Version20221026091308 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 section_data (id SERIAL NOT NULL, sport_object_id INT DEFAULT NULL, sport_section_id INT DEFAULT NULL, url VARCHAR(500) DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_284D1F688AFAE46 ON section_data (sport_object_id)');
$this->addSql('CREATE INDEX IDX_284D1F68EB0B7C67 ON section_data (sport_section_id)');
$this->addSql('CREATE UNIQUE INDEX section_data_unique ON section_data (sport_object_id, sport_section_id)');
$this->addSql('COMMENT ON TABLE section_data IS \'Связь спортивных секций со спортивными объектами и спортивными организациями.\'');
$this->addSql('ALTER TABLE section_data ADD CONSTRAINT FK_284D1F688AFAE46 FOREIGN KEY (sport_object_id) REFERENCES sport_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE section_data ADD CONSTRAINT FK_284D1F68EB0B7C67 FOREIGN KEY (sport_section_id) REFERENCES sport_section (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE sport_object_sport_section DROP CONSTRAINT fk_2b93f9ac8afae46');
$this->addSql('ALTER TABLE sport_object_sport_section DROP CONSTRAINT fk_2b93f9aceb0b7c67');
$this->addSql('DROP TABLE sport_object_sport_section');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE sport_object_sport_section (sport_object_id INT NOT NULL, sport_section_id INT NOT NULL, PRIMARY KEY(sport_object_id, sport_section_id))');
$this->addSql('CREATE INDEX idx_2b93f9aceb0b7c67 ON sport_object_sport_section (sport_section_id)');
$this->addSql('CREATE INDEX idx_2b93f9ac8afae46 ON sport_object_sport_section (sport_object_id)');
$this->addSql('ALTER TABLE sport_object_sport_section ADD CONSTRAINT fk_2b93f9ac8afae46 FOREIGN KEY (sport_object_id) REFERENCES sport_object (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE sport_object_sport_section ADD CONSTRAINT fk_2b93f9aceb0b7c67 FOREIGN KEY (sport_section_id) REFERENCES sport_section (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE section_data DROP CONSTRAINT FK_284D1F688AFAE46');
$this->addSql('ALTER TABLE section_data DROP CONSTRAINT FK_284D1F68EB0B7C67');
$this->addSql('DROP TABLE section_data');
}
}