migrations/Version20240328131826.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 Version20240328131826 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'TDP-2263 - TourCategory, tur sıralama.';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql('ALTER TABLE tour_tour_category DROP FOREIGN KEY FK_F90194F115ED8D43');
  18.         $this->addSql('ALTER TABLE tour_tour_category DROP FOREIGN KEY FK_F90194F17210CF21');
  19.         $this->addSql('ALTER TABLE tour_tour_category ADD id INT AUTO_INCREMENT NOT NULL FIRST, ADD sequence SMALLINT NOT NULL, DROP PRIMARY KEY, ADD PRIMARY KEY (id)');
  20.         $this->addSql('ALTER TABLE tour_tour_category ADD CONSTRAINT FK_F90194F115ED8D43 FOREIGN KEY (tour_id) REFERENCES tour (id)');
  21.         $this->addSql('ALTER TABLE tour_tour_category ADD CONSTRAINT FK_F90194F17210CF21 FOREIGN KEY (tour_category_id) REFERENCES tour_category (id)');
  22.         $this->addSql('CREATE UNIQUE INDEX u_tour_tour_category ON tour_tour_category (tour_id, tour_category_id)');
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         $this->addSql('ALTER TABLE tour_tour_category MODIFY id INT NOT NULL');
  27.         $this->addSql('ALTER TABLE tour_tour_category DROP FOREIGN KEY FK_F90194F17210CF21');
  28.         $this->addSql('ALTER TABLE tour_tour_category DROP FOREIGN KEY FK_F90194F115ED8D43');
  29.         $this->addSql('DROP INDEX `PRIMARY` ON tour_tour_category');
  30.         $this->addSql('ALTER TABLE tour_tour_category DROP id, DROP sequence');
  31.         $this->addSql('ALTER TABLE tour_tour_category ADD CONSTRAINT FK_F90194F17210CF21 FOREIGN KEY (tour_category_id) REFERENCES tour_category (id) ON DELETE CASCADE');
  32.         $this->addSql('ALTER TABLE tour_tour_category ADD CONSTRAINT FK_F90194F115ED8D43 FOREIGN KEY (tour_id) REFERENCES tour (id) ON DELETE CASCADE');
  33.         $this->addSql('ALTER TABLE tour_tour_category ADD PRIMARY KEY (tour_id, tour_category_id)');
  34.         $this->addSql('DROP INDEX u_tour_tour_category ON tour_tour_category');
  35.     }
  36. }