"Fossies" - the Fresh Open Source Software Archive

Member "mailman-3.3.7/src/mailman/database/alembic/versions/46e92facee7_add_serverowner_domainowner.py" (10 Nov 2022, 2192 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 "46e92facee7_add_serverowner_domainowner.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) 2015-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 """add_serverowner_domainowner
   19 
   20 Revision ID: 46e92facee7
   21 Revises: 33e1f5f6fa8
   22 Create Date: 2015-03-20 16:01:25.007242
   23 
   24 """
   25 
   26 import sqlalchemy as sa
   27 
   28 from alembic import op
   29 from mailman.database.helpers import exists_in_db, is_sqlite
   30 
   31 
   32 # Revision identifiers, used by Alembic.
   33 revision = '46e92facee7'
   34 down_revision = '33e1f5f6fa8'
   35 
   36 
   37 def upgrade():
   38     op.create_table(
   39         'domain_owner',
   40         sa.Column('user_id', sa.Integer(), nullable=False),
   41         sa.Column('domain_id', sa.Integer(), nullable=False),
   42         sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
   43         sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
   44         sa.PrimaryKeyConstraint('user_id', 'domain_id')
   45         )
   46     if not exists_in_db(op.get_bind(), 'user', 'is_server_owner'):
   47         # SQLite may not have removed it when downgrading.
   48         op.add_column(
   49             'user',
   50             sa.Column('is_server_owner', sa.Boolean(), nullable=True))
   51     if not is_sqlite(op.get_bind()):
   52         op.drop_column('domain', 'contact_address')
   53 
   54 
   55 def downgrade():
   56     if not is_sqlite(op.get_bind()):
   57         op.drop_column('user', 'is_server_owner')
   58     if not exists_in_db(op.get_bind(), 'domain', 'contact_address'):
   59         # SQLite may not have removed it.  Add a fixed length VARCHAR for
   60         # MySQL.
   61         op.add_column(
   62             'domain',
   63             sa.Column('contact_address', sa.VARCHAR(255), nullable=True))
   64     op.drop_table('domain_owner')