Add index for AliasHibp

This commit is contained in:
Son NK 2021-05-28 19:59:26 +02:00
parent c890bfb073
commit 28285f28ac
2 changed files with 37 additions and 2 deletions

View File

@ -2022,8 +2022,12 @@ class AliasHibp(db.Model, ModelMixin):
__table_args__ = (db.UniqueConstraint("alias_id", "hibp_id", name="uq_alias_hibp"),)
alias_id = db.Column(db.Integer(), db.ForeignKey("alias.id", ondelete="cascade"))
hibp_id = db.Column(db.Integer(), db.ForeignKey("hibp.id", ondelete="cascade"))
alias_id = db.Column(
db.Integer(), db.ForeignKey("alias.id", ondelete="cascade"), index=True
)
hibp_id = db.Column(
db.Integer(), db.ForeignKey("hibp.id", ondelete="cascade"), index=True
)
alias = db.relationship(
"Alias", backref=db.backref("alias_hibp", cascade="all, delete-orphan")

View File

@ -0,0 +1,31 @@
"""empty message
Revision ID: fc2eb1d7e4fc
Revises: 68e2f38e33f4
Create Date: 2021-05-28 19:59:04.259149
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'fc2eb1d7e4fc'
down_revision = '68e2f38e33f4'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(op.f('ix_alias_hibp_alias_id'), 'alias_hibp', ['alias_id'], unique=False)
op.create_index(op.f('ix_alias_hibp_hibp_id'), 'alias_hibp', ['hibp_id'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_alias_hibp_hibp_id'), table_name='alias_hibp')
op.drop_index(op.f('ix_alias_hibp_alias_id'), table_name='alias_hibp')
# ### end Alembic commands ###