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

Speeds up SSHPubKeys.PubKey searches in a larger database.

Fixed form of the original commit which was reverted,
1a7f6e1fa9

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2022-08-13 19:52:50 -07:00
parent 5abd5db313
commit 6c7e274968
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
3 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,35 @@
"""add SSHPubKeys.PubKey index
Revision ID: dd70103d2e82
Revises: d64e5571bc8d
Create Date: 2022-08-12 21:30:26.155465
"""
import traceback
from alembic import op
# revision identifiers, used by Alembic.
revision = 'dd70103d2e82'
down_revision = 'd64e5571bc8d'
branch_labels = None
depends_on = None
def upgrade():
try:
op.create_index("SSHPubKeysUserID", "SSHPubKeys", ["UserID"])
except Exception:
traceback.print_exc()
print("failing silently...")
try:
op.create_index("SSHPubKeysPubKey", "SSHPubKeys", ["PubKey"])
except Exception:
traceback.print_exc()
print("failing silently...")
def downgrade():
op.drop_index("SSHPubKeysPubKey", "SSHPubKeys")
op.drop_index("SSHPubKeysUserID", "SSHPubKeys")