"Fossies" - the Fresh Open Source Software Archive

Member "mailman-3.3.7/src/mailman/database/alembic/versions/3f31035ed0d7_further_increase_pendedkeyvalue_value_.py" (10 Nov 2022, 1336 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 "3f31035ed0d7_further_increase_pendedkeyvalue_value_.py" see the Fossies "Dox" file reference documentation.

    1 """further_increase_pendedkeyvalue_value_size
    2 
    3 Revision ID: 3f31035ed0d7
    4 Revises: 4bd95c99b2e7
    5 Create Date: 2017-10-18 17:42:35.550686
    6 
    7 """
    8 
    9 from alembic import op
   10 from mailman.database.types import SAUnicodeLarge, SAUnicodeXL
   11 
   12 
   13 # revision identifiers, used by Alembic.
   14 revision = '3f31035ed0d7'
   15 down_revision = '4bd95c99b2e7'
   16 
   17 
   18 def upgrade():
   19     # pendedkeyvalue table values can be much larger than SAUnicodeLarge
   20     with op.batch_alter_table('pendedkeyvalue') as batch_op:
   21         # Drop the existing index on the table.
   22         batch_op.drop_index(op.f('ix_pendedkeyvalue_value'))
   23         # Alter the column type and then create a new index with
   24         # mysql_length set to a fixed length value.
   25         batch_op.alter_column('value', type_=SAUnicodeXL)
   26         batch_op.create_index(op.f('ix_pendedkeyvalue_value'),
   27                               columns=['value'], mysql_length=100)
   28 
   29 
   30 def downgrade():
   31     with op.batch_alter_table('pendedkeyvalue') as batch_op:
   32         batch_op.alter_column('value', type_=SAUnicodeLarge)
   33         # Drop the existing index because it has a fixed length value and then
   34         # re-create without the length constraint.
   35         batch_op.drop_index(op.f('ix_pendedkeyvalue_value'))
   36         batch_op.create_index(op.f('ix_pendedkeyvalue_value'),
   37                               columns=['value'])