"Fossies" - the Fresh Open Source Software Archive

Member "mailman-3.3.7/src/mailman/database/alembic/versions/472e6d713047_bounce_increment.py" (10 Nov 2022, 2101 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 "472e6d713047_bounce_increment.py" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3.3.5_vs_3.3.6.

    1 # Copyright (C) 2020-2022 by the Free Software Foundation, Inc.
    2 #
    3 # This file is part of GNU Mailman.
    4 #
    5 # GNU Mailman is free software: you can redistribute it and/or modify it under
    6 # the terms of the GNU General Public License as published by the Free
    7 # Software Foundation, either version 3 of the License, or (at your option)
    8 # any later version.
    9 #
   10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
   11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   13 # more details.
   14 #
   15 # You should have received a copy of the GNU General Public License along with
   16 # GNU Mailman.  If not, see <https://www.gnu.org/licenses/>.
   17 
   18 """bounce_increment
   19 
   20 Revision ID: 472e6d713047
   21 Revises: 2b73fbcc97c9
   22 Create Date: 2021-03-29 09:50:02.904766
   23 
   24 """
   25 import sqlalchemy as sa
   26 
   27 from alembic import op
   28 from mailman.database.helpers import exists_in_db, is_sqlite
   29 
   30 
   31 # revision identifiers, used by Alembic.
   32 revision = '472e6d713047'
   33 down_revision = '2b73fbcc97c9'
   34 
   35 
   36 def upgrade():
   37     if not exists_in_db(
   38             op.get_bind(), 'mailinglist',
   39             'bounce_notify_owner_on_bounce_increment'):
   40         op.add_column(                                        # pragma: nocover
   41             'mailinglist',
   42             sa.Column('bounce_notify_owner_on_bounce_increment', sa.BOOLEAN(),
   43                       nullable=True))
   44         # Set the default data.
   45         mlist = sa.sql.table(                                 # pragma: nocover
   46             'mailinglist',
   47             sa.sql.column('bounce_notify_owner_on_bounce_increment',
   48                           sa.BOOLEAN())
   49             )
   50         op.execute(mlist.update().values(                     # pragma: nocover
   51             {'bounce_notify_owner_on_bounce_increment': False}))
   52 
   53 
   54 def downgrade():
   55     if not is_sqlite(op.get_bind()):
   56         # SQLite does not support dropping columns.
   57         op.drop_column(                                       # pragma: nocover
   58             'mailinglist',
   59             'bounce_notify_owner_on_bounce_increment')