"Fossies" - the Fresh Open Source Software Archive

Member "mailman-3.3.7/src/mailman/database/alembic/versions/98224512c9c2_mysql_extend_autoresponse_text_fields_.py" (10 Nov 2022, 2996 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 "98224512c9c2_mysql_extend_autoresponse_text_fields_.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 """MySQL: Extend autoresponse text fields, use utf8mb4
   19 
   20 Revision ID: 98224512c9c2
   21 Revises: bc0c49c6dda2
   22 Create Date: 2021-07-06 18:29:14.583453
   23 
   24 """
   25 from alembic import op
   26 from mailman.database.helpers import is_mysql
   27 from mailman.database.types import SAText, SAUnicode4Byte
   28 from sqlalchemy.dialects import mysql
   29 
   30 
   31 # revision identifiers, used by Alembic.
   32 revision = '98224512c9c2'
   33 down_revision = 'bc0c49c6dda2'
   34 
   35 
   36 def upgrade():  # pragma: nocover
   37     with op.batch_alter_table('mailinglist', schema=None) as batch_op:
   38         batch_op.alter_column(
   39             'autoresponse_owner_text',
   40             existing_type=SAUnicode4Byte(),
   41             type_=SAText(),
   42             existing_nullable=True)
   43         batch_op.alter_column(
   44             'autoresponse_postings_text',
   45             existing_type=SAUnicode4Byte(),
   46             type_=SAText(),
   47             existing_nullable=True)
   48         batch_op.alter_column(
   49             'autoresponse_request_text',
   50             existing_type=SAUnicode4Byte(),
   51             type_=SAText(),
   52             existing_nullable=True)
   53         if is_mysql(op.get_bind()):
   54             # MySQL-only, switch info to utf8mb4 charset
   55             batch_op.alter_column(
   56                 'info',
   57                 existing_type=mysql.TEXT(charset='utf8', collation='utf8_bin'),
   58                 type_=SAText(),
   59                 existing_nullable=True)
   60 
   61 
   62 def downgrade():  # pragma: nocover
   63     with op.batch_alter_table('mailinglist', schema=None) as batch_op:
   64         if is_mysql(op.get_bind()):
   65             batch_op.alter_column(
   66                 'info',
   67                 existing_type=SAText(),
   68                 type_=mysql.TEXT(charset='utf8', collation='utf8_bin'),
   69                 existing_nullable=True)
   70         batch_op.alter_column(
   71             'autoresponse_request_text',
   72             existing_type=SAText(),
   73             type_=SAUnicode4Byte(),
   74             existing_nullable=True)
   75         batch_op.alter_column(
   76             'autoresponse_postings_text',
   77             existing_type=SAText(),
   78             type_=SAUnicode4Byte(),
   79             existing_nullable=True)
   80         batch_op.alter_column(
   81             'autoresponse_owner_text',
   82             existing_type=SAText(),
   83             type_=SAUnicode4Byte(),
   84             existing_nullable=True)