Skip to content

Commit a936921

Browse files
Use constant for sort key index size
1 parent e5045a6 commit a936921

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

webapp/migrations/Version20250309122806.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace DoctrineMigrations;
66

7+
use App\Entity\RankCache;
78
use Doctrine\DBAL\Schema\Schema;
89
use Doctrine\Migrations\AbstractMigration;
910

@@ -21,8 +22,8 @@ public function up(Schema $schema): void
2122
{
2223
// this up() migration is auto-generated, please modify it to your needs
2324
$this->addSql('ALTER TABLE rankcache ADD sort_key_public TEXT DEFAULT \'\' NOT NULL COMMENT \'Opaque sort key for public audience.\', ADD sort_key_restricted TEXT DEFAULT \'\' NOT NULL COMMENT \'Opaque sort key for restricted audience.\'');
24-
$this->addSql('CREATE INDEX sortKeyPublic ON rankcache (sort_key_public)');
25-
$this->addSql('CREATE INDEX sortKeyRestricted ON rankcache (sort_key_restricted)');
25+
$this->addSql(sprintf('CREATE INDEX sortKeyPublic ON rankcache (sort_key_public(%s))', RankCache::SORT_KEY_INDEX_SIZE));
26+
$this->addSql(sprintf('CREATE INDEX sortKeyRestricted ON rankcache (sort_key_restricted(%s))', RankCache::SORT_KEY_INDEX_SIZE));
2627
}
2728

2829
public function down(Schema $schema): void

webapp/src/Entity/RankCache.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
#[ORM\Index(columns: ['cid', 'points_public', 'totaltime_public', 'totalruntime_public'], name: 'order_public')]
2020
#[ORM\Index(columns: ['cid'], name: 'cid')]
2121
#[ORM\Index(columns: ['teamid'], name: 'teamid')]
22-
#[ORM\Index(columns: ['sort_key_public'], name: 'sortKeyPublic', options: ['lengths' => [768]])]
23-
#[ORM\Index(columns: ['sort_key_restricted'], name: 'sortKeyRestricted', options: ['lengths' => [768]])]
22+
#[ORM\Index(columns: ['sort_key_public'], name: 'sortKeyPublic', options: ['lengths' => [self::SORT_KEY_INDEX_SIZE]])]
23+
#[ORM\Index(columns: ['sort_key_restricted'], name: 'sortKeyRestricted', options: ['lengths' => [self::SORT_KEY_INDEX_SIZE]])]
2424
class RankCache
2525
{
26+
public const SORT_KEY_INDEX_SIZE = 768;
27+
2628
#[ORM\Column(options: [
2729
'comment' => 'Total correctness points (restricted audience)',
2830
'unsigned' => true,

0 commit comments

Comments
 (0)