Commit 85fcd446 authored by Aurélien Bompard's avatar Aurélien Bompard Committed by Barry Warsaw

Add indexes on the Pendable fields that can be queried upon.

- Pendable.token: queried in the add() and confirm() methods
- Pendable.expiration_date: queried on evict()
- PendableKeyValue.key and PendableKeyValue.value: queried in the find()
  method
parent 08e22a84
"""Pendable indexes
Add indexes on Pendable fields that can be queried upon.
Revision ID: 47294d3a604
Revises: 33bc0099223
Create Date: 2015-12-02 11:46:47.295174
"""
# revision identifiers, used by Alembic.
revision = '47294d3a604'
down_revision = '33bc0099223'
from alembic import op
def upgrade():
op.create_index(
op.f('ix_pended_expiration_date'), 'pended', ['expiration_date'],
unique=False)
op.create_index(op.f('ix_pended_token'), 'pended', ['token'], unique=False)
op.create_index(
op.f('ix_pendedkeyvalue_key'), 'pendedkeyvalue', ['key'], unique=False)
op.create_index(
op.f('ix_pendedkeyvalue_value'), 'pendedkeyvalue', ['value'],
unique=False)
def downgrade():
op.drop_index(op.f('ix_pendedkeyvalue_value'), table_name='pendedkeyvalue')
op.drop_index(op.f('ix_pendedkeyvalue_key'), table_name='pendedkeyvalue')
op.drop_index(op.f('ix_pended_token'), table_name='pended')
op.drop_index(op.f('ix_pended_expiration_date'), table_name='pended')
......@@ -49,14 +49,10 @@ class PendedKeyValue(Model):
__tablename__ = 'pendedkeyvalue'
id = Column(Integer, primary_key=True)
key = Column(Unicode)
value = Column(Unicode)
key = Column(Unicode, index=True)
value = Column(Unicode, index=True)
pended_id = Column(Integer, ForeignKey('pended.id'), index=True)
def __init__(self, key, value):
self.key = key
self.value = value
@implementer(IPended)
......@@ -66,15 +62,10 @@ class Pended(Model):
__tablename__ = 'pended'
id = Column(Integer, primary_key=True)
token = Column(Unicode)
expiration_date = Column(DateTime)
token = Column(Unicode, index=True)
expiration_date = Column(DateTime, index=True)
key_values = relationship('PendedKeyValue', cascade="all, delete-orphan")
def __init__(self, token, expiration_date):
super(Pended, self).__init__()
self.token = token
self.expiration_date = expiration_date
@implementer(IPendable)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment