feat(db): add an index for SSHPubKeys.PubKey

Speeds up SSHPubKeys.PubKey searches in a larger database.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2022-08-12 21:37:34 -07:00
parent 913ce8a4f0
commit 1a7f6e1fa9
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
3 changed files with 52 additions and 0 deletions

23
test/test_migration.py Normal file
View file

@ -0,0 +1,23 @@
import pytest
from sqlalchemy import inspect
from aurweb.db import get_engine
from aurweb.models.ssh_pub_key import SSHPubKey
@pytest.fixture(autouse=True)
def setup(db_test):
return
def test_sshpubkeys_pubkey_index():
insp = inspect(get_engine())
indexes = insp.get_indexes(SSHPubKey.__tablename__)
found_pk = False
for idx in indexes:
if idx.get("name") == "SSHPubKeysPubKey":
assert idx.get("column_names") == ["PubKey"]
found_pk = True
assert found_pk