diff options
| author | Barry Warsaw | 2016-08-30 21:02:06 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2016-09-01 06:55:09 -0400 |
| commit | 84c0f9532ae20d0f5ee8a8ecd9a92e42925b174b (patch) | |
| tree | 8df7ada1e3eedfeca584062fbc3e5507e1b70ed7 /src/mailman/database | |
| parent | 975b5e0af2759e5fb7c6d10ddd4923127b7ec442 (diff) | |
| download | mailman-84c0f9532ae20d0f5ee8a8ecd9a92e42925b174b.tar.gz mailman-84c0f9532ae20d0f5ee8a8ecd9a92e42925b174b.tar.zst mailman-84c0f9532ae20d0f5ee8a8ecd9a92e42925b174b.zip | |
Checkpointing
Diffstat (limited to 'src/mailman/database')
| -rw-r--r-- | src/mailman/database/alembic/versions/448a93984c35_unsubscription_workflow.py | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/mailman/database/alembic/versions/448a93984c35_unsubscription_workflow.py b/src/mailman/database/alembic/versions/448a93984c35_unsubscription_workflow.py index 51be76051..64fcdffcd 100644 --- a/src/mailman/database/alembic/versions/448a93984c35_unsubscription_workflow.py +++ b/src/mailman/database/alembic/versions/448a93984c35_unsubscription_workflow.py @@ -3,32 +3,34 @@ Revision ID: 448a93984c35 Revises: 7b254d88f122 Create Date: 2016-06-02 14:34:24.154723 - """ -# revision identifiers, used by Alembic. -revision = '448a93984c35' -down_revision = '7b254d88f122' - import sqlalchemy as sa from alembic import op -from mailman.database.helpers import is_sqlite, exists_in_db +from mailman.database.helpers import exists_in_db from mailman.database.types import Enum from mailman.interfaces.mailinglist import SubscriptionPolicy + +# revision identifiers, used by Alembic. +revision = '448a93984c35' +down_revision = '7b254d88f122' + + def upgrade(): if not exists_in_db(op.get_bind(), 'mailinglist', 'unsubscription_policy'): - # SQLite may not have removed it when downgrading. - op.add_column('mailinglist', sa.Column( - 'unsubscription_policy', Enum(SubscriptionPolicy), nullable=True)) - + with op.batch_alter_table('mailinglist') as batch_op: + # SQLite may not have removed it when downgrading. + batch_op.add_column('mailinglist', sa.Column( + 'unsubscription_policy', Enum(SubscriptionPolicy), + nullable=True)) # Now migrate the data. Don't import the table definition from the # models, it may break this migration when the model is updated in the # future (see the Alembic doc). mlist = sa.sql.table( 'mailinglist', sa.sql.column('unsubscription_policy', Enum(SubscriptionPolicy)) - ) + ) # There were no enforced subscription policy before, so all lists are # considered open. op.execute(mlist.update().values( @@ -37,6 +39,5 @@ def upgrade(): def downgrade(): - if not is_sqlite(op.get_bind()): - # SQLite does not support dropping columns. - op.drop_column('mailinglist', 'unsubscription_policy') + with op.batch_alter_table('mailinglist') as batch_op: + batch_op.drop_column('mailinglist', 'unsubscription_policy') |
