migrations/Version20221114100127.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 Version20221114100127 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 sport_event_sport (sport_event_id INT NOT NULL, sport_id INT NOT NULL, PRIMARY KEY(sport_event_id, sport_id))');
  19.         $this->addSql('CREATE INDEX IDX_38AB1AB847551731 ON sport_event_sport (sport_event_id)');
  20.         $this->addSql('CREATE INDEX IDX_38AB1AB8AC78BCF8 ON sport_event_sport (sport_id)');
  21.         $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');
  22.         $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');
  23.         $this->addSql('ALTER TABLE sport_event DROP CONSTRAINT fk_8fd26bbe8bac62af');
  24.         $this->addSql('ALTER TABLE sport_event DROP CONSTRAINT fk_8fd26bbeac78bcf8');
  25.         $this->addSql('DROP INDEX idx_8fd26bbe8bac62af');
  26.         $this->addSql('DROP INDEX idx_8fd26bbeac78bcf8');
  27.         $this->addSql('ALTER TABLE sport_event ADD published_by_id INT DEFAULT NULL');
  28.         $this->addSql('ALTER TABLE sport_event ADD link_ticket VARCHAR(255) DEFAULT NULL');
  29.         $this->addSql('ALTER TABLE sport_event ADD is_published BOOLEAN DEFAULT NULL');
  30.         $this->addSql('ALTER TABLE sport_event ADD entrance_type VARCHAR(255) DEFAULT NULL');
  31.         $this->addSql('ALTER TABLE sport_event ADD published_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
  32.         $this->addSql('ALTER TABLE sport_event DROP sport_id');
  33.         $this->addSql('ALTER TABLE sport_event DROP city_id');
  34.         $this->addSql('COMMENT ON COLUMN sport_event.link_ticket IS \'Ссылка на продажу билетов\'');
  35.         $this->addSql('COMMENT ON COLUMN sport_event.is_published IS \'Признак публикации\'');
  36.         $this->addSql('COMMENT ON COLUMN sport_event.entrance_type IS \'Тип входа (свободный, по билетам)\'');
  37.         $this->addSql('COMMENT ON COLUMN sport_event.published_at IS \'Дата публикации\'');
  38.         $this->addSql('COMMENT ON COLUMN sport_event.link_broadcast IS \'Ссылка на трансляцию\'');
  39.         $this->addSql('ALTER TABLE sport_event ADD CONSTRAINT FK_8FD26BBE5B075477 FOREIGN KEY (published_by_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  40.         $this->addSql('CREATE INDEX IDX_8FD26BBE5B075477 ON sport_event (published_by_id)');
  41.     }
  42.     public function down(Schema $schema): void
  43.     {
  44.         // this down() migration is auto-generated, please modify it to your needs
  45.         $this->addSql('ALTER TABLE sport_event_sport DROP CONSTRAINT FK_38AB1AB847551731');
  46.         $this->addSql('ALTER TABLE sport_event_sport DROP CONSTRAINT FK_38AB1AB8AC78BCF8');
  47.         $this->addSql('DROP TABLE sport_event_sport');
  48.         $this->addSql('ALTER TABLE sport_event DROP CONSTRAINT FK_8FD26BBE5B075477');
  49.         $this->addSql('DROP INDEX IDX_8FD26BBE5B075477');
  50.         $this->addSql('ALTER TABLE sport_event ADD city_id INT DEFAULT NULL');
  51.         $this->addSql('ALTER TABLE sport_event DROP link_ticket');
  52.         $this->addSql('ALTER TABLE sport_event DROP is_published');
  53.         $this->addSql('ALTER TABLE sport_event DROP entrance_type');
  54.         $this->addSql('ALTER TABLE sport_event DROP published_at');
  55.         $this->addSql('ALTER TABLE sport_event RENAME COLUMN published_by_id TO sport_id');
  56.         $this->addSql('COMMENT ON COLUMN sport_event.link_broadcast IS \'ссылка на трансляцию\'');
  57.         $this->addSql('ALTER TABLE sport_event ADD CONSTRAINT fk_8fd26bbe8bac62af FOREIGN KEY (city_id) REFERENCES city (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  58.         $this->addSql('ALTER TABLE sport_event ADD CONSTRAINT fk_8fd26bbeac78bcf8 FOREIGN KEY (sport_id) REFERENCES sport (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  59.         $this->addSql('CREATE INDEX idx_8fd26bbe8bac62af ON sport_event (city_id)');
  60.         $this->addSql('CREATE INDEX idx_8fd26bbeac78bcf8 ON sport_event (sport_id)');
  61.     }
  62. }