"Fossies" - the Fresh Open Source Software Archive

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

    1 """digests
    2 
    3 Revision ID: 70af5a4e5790
    4 Revises: 47294d3a604
    5 Create Date: 2015-12-19 12:05:42.202998
    6 
    7 """
    8 
    9 import os
   10 import sqlalchemy as sa
   11 
   12 from alembic import op
   13 from mailman.config import config
   14 
   15 
   16 # Revision identifiers, used by Alembic.
   17 revision = '70af5a4e5790'
   18 down_revision = '47294d3a604'
   19 
   20 
   21 def upgrade():
   22     with op.batch_alter_table('mailinglist') as batch_op:
   23         batch_op.alter_column('digestable',
   24                               new_column_name='digests_enabled',
   25                               existing_type=sa.Boolean)
   26         # All column modifications require existing types for Mysql.
   27         batch_op.drop_column('nondigestable')
   28     # Non-database migration: rename the list's data-path.
   29     for dirname in os.listdir(config.LIST_DATA_DIR):
   30         if '@' in dirname:
   31             old_name = os.path.join(config.LIST_DATA_DIR, dirname)
   32             listname, at, domain = dirname.partition('@')
   33             new_name = os.path.join(config.LIST_DATA_DIR,
   34                                     '{}.{}'.format(listname, domain))
   35             os.rename(old_name, new_name)
   36 
   37 
   38 def downgrade():
   39     with op.batch_alter_table('mailinglist') as batch_op:
   40         batch_op.alter_column('digests_enabled',
   41                               new_column_name='digestable',
   42                               existing_type=sa.Boolean)
   43         # The data for this column is lost, it's not used anyway.
   44         batch_op.add_column(sa.Column('nondigestable', sa.Boolean))
   45     for dirname in os.listdir(config.LIST_DATA_DIR):
   46         if '@' not in dirname:
   47             old_name = os.path.join(config.LIST_DATA_DIR, dirname)
   48             listname, domain = dirname.split('.', 1)
   49             new_name = os.path.join(config.LIST_DATA_DIR,
   50                                     '{}@{}'.format(listname, domain))
   51             os.rename(old_name, new_name)