"Fossies" - the Fresh Open Source Software Archive

Member "mailman-3.3.7/src/mailman/database/alembic/versions/33bc0099223_add_member_indexes.py" (10 Nov 2022, 1486 Bytes) of package /linux/misc/mailman-3.3.7.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "33bc0099223_add_member_indexes.py" see the Fossies "Dox" file reference documentation.

    1 """Add member indexes
    2 
    3 Revision ID: 33bc0099223
    4 Revises: 42756496720
    5 Create Date: 2015-11-19 23:04:42.449553
    6 
    7 """
    8 
    9 from alembic import op
   10 from mailman.database.helpers import is_mysql
   11 
   12 
   13 # Revision identifiers, used by Alembic.
   14 revision = '33bc0099223'
   15 down_revision = '42756496720'
   16 
   17 
   18 def upgrade():
   19     op.create_index(op.f('ix_address_email'),
   20                     'address', ['email'],
   21                     unique=False)
   22     # MySQL automatically creates the indexes for primary keys so don't need
   23     # to do it explicitly again.
   24     if not is_mysql(op.get_bind()):
   25         op.create_index(op.f('ix_member_address_id'),
   26                         'member', ['address_id'],
   27                         unique=False)
   28         op.create_index(op.f('ix_member_preferences_id'),
   29                         'member', ['preferences_id'],
   30                         unique=False)
   31         op.create_index(op.f('ix_member_user_id'),
   32                         'member', ['user_id'],
   33                         unique=False)
   34 
   35 
   36 def downgrade():
   37     op.drop_index(op.f('ix_address_email'), table_name='address')
   38     # MySQL automatically creates and removes the indexes for primary keys.
   39     # So, you cannot drop it without removing the foreign key constraint.
   40     if not is_mysql(op.get_bind()):
   41         op.drop_index(op.f('ix_member_user_id'), table_name='member')
   42         op.drop_index(op.f('ix_member_preferences_id'), table_name='member')
   43         op.drop_index(op.f('ix_member_address_id'), table_name='member')