Commit 9708493d authored by Aurélien Bompard's avatar Aurélien Bompard Committed by Barry Warsaw

Add useful indexes on the member table

parent 0226456b
Pipeline #272146 passed with stage
"""Add member indexes
Revision ID: 33bc0099223
Revises: 42756496720
Create Date: 2015-11-19 23:04:42.449553
"""
# Revision identifiers, used by Alembic.
revision = '33bc0099223'
down_revision = '42756496720'
from alembic import op
def upgrade():
op.create_index(op.f('ix_member_address_id'),
'member', ['address_id'],
unique=False)
op.create_index(op.f('ix_member_preferences_id'),
'member', ['preferences_id'],
unique=False)
op.create_index(op.f('ix_member_user_id'),
'member', ['user_id'],
unique=False)
op.create_index(op.f('ix_address_email'),
'address', ['email'],
unique=False)
def downgrade():
op.drop_index(op.f('ix_address_email'), table_name='address')
op.drop_index(op.f('ix_member_user_id'), table_name='member')
op.drop_index(op.f('ix_member_preferences_id'), table_name='member')
op.drop_index(op.f('ix_member_address_id'), table_name='member')
......@@ -42,7 +42,7 @@ class Address(Model):
__tablename__ = 'address'
id = Column(Integer, primary_key=True)
email = Column(Unicode)
email = Column(Unicode, index=True)
_original = Column(Unicode)
display_name = Column(Unicode)
_verified_on = Column('verified_on', DateTime)
......
......@@ -57,11 +57,11 @@ class Member(Model):
list_id = Column(Unicode)
moderation_action = Column(Enum(Action))
address_id = Column(Integer, ForeignKey('address.id'))
address_id = Column(Integer, ForeignKey('address.id'), index=True)
_address = relationship('Address')
preferences_id = Column(Integer, ForeignKey('preferences.id'))
preferences_id = Column(Integer, ForeignKey('preferences.id'), index=True)
preferences = relationship('Preferences')
user_id = Column(Integer, ForeignKey('user.id'))
user_id = Column(Integer, ForeignKey('user.id'), index=True)
_user = relationship('User')
def __init__(self, role, list_id, subscriber):
......
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