Skip to content

Commit

Permalink
add indexes for searchable properties
Browse files Browse the repository at this point in the history
  • Loading branch information
usu committed Apr 16, 2022
1 parent 2b86b29 commit f181d4a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions api/migrations/schema/Version20220416125104.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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 Version20220416125104 extends AbstractMigration {
public function getDescription(): string {
return 'add indexed for searchable properties';
}

public function up(Schema $schema): void {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE INDEX IDX_C19442309AF2EB23 ON camp (isPrototype)');
$this->addSql('CREATE INDEX IDX_C93898A7B00651C ON camp_collaboration (status)');
$this->addSql('CREATE INDEX IDX_D7785D2CA1CB398B ON schedule_entry (startOffset)');
$this->addSql('CREATE INDEX IDX_D7785D2CA501647F ON schedule_entry (endOffset)');
}

public function down(Schema $schema): void {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP INDEX IDX_D7785D2CA1CB398B');
$this->addSql('DROP INDEX IDX_D7785D2CA501647F');
$this->addSql('DROP INDEX IDX_C19442309AF2EB23');
$this->addSql('DROP INDEX IDX_C93898A7B00651C');
}
}
1 change: 1 addition & 0 deletions api/src/Entity/Camp.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
)]
#[ApiFilter(SearchFilter::class, properties: ['isPrototype'])]
#[ORM\Entity(repositoryClass: CampRepository::class)]
#[ORM\Index(columns: ['isPrototype'])]
class Camp extends BaseEntity implements BelongsToCampInterface, CopyFromPrototypeInterface {
public const ITEM_NORMALIZATION_CONTEXT = [
'groups' => ['read', 'Camp:Periods', 'Period:Days', 'Camp:CampCollaborations', 'CampCollaboration:User'],
Expand Down
1 change: 1 addition & 0 deletions api/src/Entity/CampCollaboration.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
#[ORM\UniqueConstraint(name: 'inviteKeyHash_unique', columns: ['inviteKeyHash'])]
#[ORM\UniqueConstraint(name: 'user_camp_unique', fields: ['user', 'camp'])]
#[ORM\UniqueConstraint(name: 'inviteEmail_camp_unique', fields: ['inviteEmail', 'camp'])]
#[ORM\Index(columns: ['status'])]
class CampCollaboration extends BaseEntity implements BelongsToCampInterface {
public const ITEM_NORMALIZATION_CONTEXT = [
'groups' => ['read', 'CampCollaboration:Camp', 'CampCollaboration:User'],
Expand Down
2 changes: 2 additions & 0 deletions api/src/Entity/ScheduleEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
'end' => 'DATE_ADD({period.start}, {}.endOffset, \'minute\')',
])]
#[ORM\Entity(repositoryClass: ScheduleEntryRepository::class)]
#[ORM\Index(columns: ['startOffset'])]
#[ORM\Index(columns: ['endOffset'])]
class ScheduleEntry extends BaseEntity implements BelongsToCampInterface {
public const ITEM_NORMALIZATION_CONTEXT = [
'groups' => ['read', 'ScheduleEntry:Activity'],
Expand Down

0 comments on commit f181d4a

Please sign in to comment.