"Fossies" - the Fresh Open Source Software Archive

Member "mailman-3.3.7/src/mailman/database/alembic/versions/51b7f92bd06c_initial.py" (10 Nov 2022, 2080 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 "51b7f92bd06c_initial.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) 2014-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 """Initial migration.
   19 
   20 This empty migration file makes sure there is always an alembic_version
   21 in the database.  As a consequence, if the database version is reported
   22 as None, it means the database needs to be created from scratch with
   23 SQLAlchemy itself.
   24 
   25 It also removes schema items left over from Storm.
   26 
   27 Revision ID: 51b7f92bd06c
   28 Revises: None
   29 Create Date: 2014-10-10 09:53:35.624472
   30 """
   31 
   32 import sqlalchemy as sa
   33 
   34 from alembic import op
   35 from mailman.database.helpers import exists_in_db, is_sqlite
   36 
   37 
   38 # Revision identifiers, used by Alembic.
   39 revision = '51b7f92bd06c'
   40 down_revision = None
   41 
   42 
   43 def upgrade():
   44     op.drop_table('version')
   45     if not is_sqlite(op.get_bind()):
   46         # SQLite does not support dropping columns.
   47         op.drop_column('mailinglist', 'acceptable_aliases_id')
   48     op.create_index(op.f('ix_user__user_id'), 'user',
   49                     ['_user_id'], unique=False)
   50     op.drop_index('ix_user_user_id', table_name='user')
   51 
   52 
   53 def downgrade():
   54     op.create_table('version')
   55     op.create_index('ix_user_user_id', 'user', ['_user_id'], unique=False)
   56     op.drop_index(op.f('ix_user__user_id'), table_name='user')
   57     if not exists_in_db(op.get_bind(), 'mailinglist', 'acceptable_aliases_id'):
   58         op.add_column(
   59             'mailinglist',
   60             sa.Column('acceptable_aliases_id', sa.INTEGER(), nullable=True))