summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAurélien Bompard2015-12-02 11:49:19 +0100
committerBarry Warsaw2015-12-16 11:04:25 -0500
commit85fcd4469703c2f234ed1a8554264f5d10151dcf (patch)
treee5b2e70d4724188ffc5ca418e51193b8c03d4f6c /src
parent08e22a84b5dd9c00373181068803c9d788c74eb9 (diff)
downloadmailman-85fcd4469703c2f234ed1a8554264f5d10151dcf.tar.gz
mailman-85fcd4469703c2f234ed1a8554264f5d10151dcf.tar.zst
mailman-85fcd4469703c2f234ed1a8554264f5d10151dcf.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/database/alembic/versions/47294d3a604_pendable_indexes.py35
-rw-r--r--src/mailman/model/pending.py17
2 files changed, 39 insertions, 13 deletions
diff --git a/src/mailman/database/alembic/versions/47294d3a604_pendable_indexes.py b/src/mailman/database/alembic/versions/47294d3a604_pendable_indexes.py
new file mode 100644
index 000000000..6ad5c7bd5
--- /dev/null
+++ b/src/mailman/database/alembic/versions/47294d3a604_pendable_indexes.py
@@ -0,0 +1,35 @@
+"""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')
diff --git a/src/mailman/model/pending.py b/src/mailman/model/pending.py
index 54188c39f..c99ac8ee1 100644
--- a/src/mailman/model/pending.py
+++ b/src/mailman/model/pending.py
@@ -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)