perf(db): composite index on wallet_transactions(user_id, type) (M14)

Helps the per-type SUM balance query. M13 (service_items.section_id) and M15
(clinic_doctor_invitations.doctor_id) were false positives — both columns carry
a FK and are therefore auto-indexed by InnoDB; verified against the live schema.

Structural regression: InfraSmokeTest::testWalletUserTypeIndexExists.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-28 20:28:24 +03:30
co-authored by Claude Opus 4.8
parent 670cef24f4
commit 447482c2ea
4 changed files with 47 additions and 3 deletions
+12
View File
@@ -31,4 +31,16 @@ class InfraSmokeTest extends ApiTestCase
$this->assertTrue($body['success']);
$this->assertSame($user->getUuid(), $body['data']['uuid']);
}
public function testWalletUserTypeIndexExists(): void
{
$conn = $this->em->getConnection();
$count = (int) $conn->fetchOne(
"SELECT COUNT(*) FROM information_schema.STATISTICS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'wallet_transactions'
AND INDEX_NAME = 'idx_wallet_user_type'"
);
$this->assertGreaterThan(0, $count, 'composite index idx_wallet_user_type is missing');
}
}