migrations/Version20240905115519.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Driver\Exception;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. /**
  8.  * Auto-generated Migration: Please modify to your needs!
  9.  */
  10. final class Version20240905115519 extends AbstractMigration
  11. {
  12.     public function getDescription(): string
  13.     {
  14.         return 'Added indexes';
  15.     }
  16.     public function up(Schema $schema): void
  17.     {
  18.         // this up() migration is auto-generated, please modify it to your needs
  19.         try {
  20.             $this->connection->executeQuery("CREATE INDEX object_id_index ON auction_bid (object_id);");
  21.         } catch (Exception $e) {
  22.             if ($e->getCode() == 1061) {
  23.                 // Index already exists
  24.             } else {
  25.                 throw $e;
  26.             }
  27.         }
  28.         try {
  29.             $this->connection->executeQuery("CREATE INDEX status_index ON notification_customer (status);");
  30.         } catch (Exception $e) {
  31.             if ($e->getCode() == 1061) {
  32.                 // Index already exists
  33.             } else {
  34.                 throw $e;
  35.             }
  36.         }
  37.         try {
  38.             $this->connection->executeQuery("CREATE INDEX related_item_id_index ON notification_customer (related_item_id);");
  39.         } catch (Exception $e) {
  40.             if ($e->getCode() == 1061) {
  41.                 // Index already exists
  42.             } else {
  43.                 throw $e;
  44.             }
  45.         }
  46.         try {
  47.             $this->connection->executeQuery("CREATE INDEX notification_type_index ON notification_template (notification_type);");
  48.         } catch (Exception $e) {
  49.             if ($e->getCode() == 1061) {
  50.                 // Index already exists
  51.             } else {
  52.                 throw $e;
  53.             }
  54.         }
  55.     }
  56.     public function down(Schema $schema): void
  57.     {
  58.         // this down() migration is auto-generated, please modify it to your needs
  59.         $this->addSql('DROP INDEX object_id_index ON auction_bid');
  60.         $this->addSql('DROP INDEX status_index ON notification_customer');
  61.         $this->addSql('DROP INDEX related_item_id_index ON notification_customer');
  62.         $this->addSql('DROP INDEX notification_type_index ON notification_type');
  63.     }
  64. }