Skip to content

Commit

Permalink
misc: added indexes to improve search speed
Browse files Browse the repository at this point in the history
  • Loading branch information
amvid committed May 14, 2024
1 parent 4a9d41c commit 7978d14
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions migrations/Version20240514121633.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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 Version20240514121633 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 INDEX airport_search_idx ON airport (title, is_active)');
$this->addSql('CREATE INDEX city_search_idx ON city (title)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX city_search_idx ON city');
$this->addSql('DROP INDEX airport_search_idx ON airport');
}
}
1 change: 1 addition & 0 deletions src/Airport/Entity/Airport.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#[ORM\Entity(repositoryClass: AirportRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[ORM\Index(columns: ['title', 'is_active'], name: 'airport_search_idx')]
#[UniqueEntity('iata')]
class Airport
{
Expand Down
1 change: 1 addition & 0 deletions src/City/Entity/City.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#[ORM\Entity(repositoryClass: CityRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[ORM\UniqueConstraint(name: 'city_title__country_unique', columns: ['country_id', 'title'])]
#[ORM\Index(columns: ['title'], name: 'city_search_idx')]
#[UniqueEntity('iata')]
class City
{
Expand Down

0 comments on commit 7978d14

Please sign in to comment.