<?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 Version20221114100127 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 sport_event_sport (sport_event_id INT NOT NULL, sport_id INT NOT NULL, PRIMARY KEY(sport_event_id, sport_id))');
$this->addSql('CREATE INDEX IDX_38AB1AB847551731 ON sport_event_sport (sport_event_id)');
$this->addSql('CREATE INDEX IDX_38AB1AB8AC78BCF8 ON sport_event_sport (sport_id)');
$this->addSql('ALTER TABLE sport_event_sport ADD CONSTRAINT FK_38AB1AB847551731 FOREIGN KEY (sport_event_id) REFERENCES sport_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE sport_event_sport ADD CONSTRAINT FK_38AB1AB8AC78BCF8 FOREIGN KEY (sport_id) REFERENCES sport (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE sport_event DROP CONSTRAINT fk_8fd26bbe8bac62af');
$this->addSql('ALTER TABLE sport_event DROP CONSTRAINT fk_8fd26bbeac78bcf8');
$this->addSql('DROP INDEX idx_8fd26bbe8bac62af');
$this->addSql('DROP INDEX idx_8fd26bbeac78bcf8');
$this->addSql('ALTER TABLE sport_event ADD published_by_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE sport_event ADD link_ticket VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE sport_event ADD is_published BOOLEAN DEFAULT NULL');
$this->addSql('ALTER TABLE sport_event ADD entrance_type VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE sport_event ADD published_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
$this->addSql('ALTER TABLE sport_event DROP sport_id');
$this->addSql('ALTER TABLE sport_event DROP city_id');
$this->addSql('COMMENT ON COLUMN sport_event.link_ticket IS \'Ссылка на продажу билетов\'');
$this->addSql('COMMENT ON COLUMN sport_event.is_published IS \'Признак публикации\'');
$this->addSql('COMMENT ON COLUMN sport_event.entrance_type IS \'Тип входа (свободный, по билетам)\'');
$this->addSql('COMMENT ON COLUMN sport_event.published_at IS \'Дата публикации\'');
$this->addSql('COMMENT ON COLUMN sport_event.link_broadcast IS \'Ссылка на трансляцию\'');
$this->addSql('ALTER TABLE sport_event ADD CONSTRAINT FK_8FD26BBE5B075477 FOREIGN KEY (published_by_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_8FD26BBE5B075477 ON sport_event (published_by_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE sport_event_sport DROP CONSTRAINT FK_38AB1AB847551731');
$this->addSql('ALTER TABLE sport_event_sport DROP CONSTRAINT FK_38AB1AB8AC78BCF8');
$this->addSql('DROP TABLE sport_event_sport');
$this->addSql('ALTER TABLE sport_event DROP CONSTRAINT FK_8FD26BBE5B075477');
$this->addSql('DROP INDEX IDX_8FD26BBE5B075477');
$this->addSql('ALTER TABLE sport_event ADD city_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE sport_event DROP link_ticket');
$this->addSql('ALTER TABLE sport_event DROP is_published');
$this->addSql('ALTER TABLE sport_event DROP entrance_type');
$this->addSql('ALTER TABLE sport_event DROP published_at');
$this->addSql('ALTER TABLE sport_event RENAME COLUMN published_by_id TO sport_id');
$this->addSql('COMMENT ON COLUMN sport_event.link_broadcast IS \'ссылка на трансляцию\'');
$this->addSql('ALTER TABLE sport_event ADD CONSTRAINT fk_8fd26bbe8bac62af FOREIGN KEY (city_id) REFERENCES city (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE sport_event ADD CONSTRAINT fk_8fd26bbeac78bcf8 FOREIGN KEY (sport_id) REFERENCES sport (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX idx_8fd26bbe8bac62af ON sport_event (city_id)');
$this->addSql('CREATE INDEX idx_8fd26bbeac78bcf8 ON sport_event (sport_id)');
}
}