summaryrefslogtreecommitdiff
path: root/src/mailman/database
diff options
context:
space:
mode:
authorAbhilash Raj2016-07-30 21:06:57 -0700
committerBarry Warsaw2016-09-01 06:55:09 -0400
commit88f349900ea9afea30186c3c9f0f399ff69f6c4a (patch)
tree984a31ab8be58871bacf4a5821ddc611ac4586fe /src/mailman/database
parentc23519b5262fd264ed0f9e5bc23b901ed7eee632 (diff)
downloadmailman-88f349900ea9afea30186c3c9f0f399ff69f6c4a.tar.gz
mailman-88f349900ea9afea30186c3c9f0f399ff69f6c4a.tar.zst
mailman-88f349900ea9afea30186c3c9f0f399ff69f6c4a.zip
Intermediate Commit
Diffstat (limited to 'src/mailman/database')
-rw-r--r--src/mailman/database/alembic/versions/448a93984c35_unsubscription_workflow.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/mailman/database/alembic/versions/448a93984c35_unsubscription_workflow.py b/src/mailman/database/alembic/versions/448a93984c35_unsubscription_workflow.py
new file mode 100644
index 000000000..51be76051
--- /dev/null
+++ b/src/mailman/database/alembic/versions/448a93984c35_unsubscription_workflow.py
@@ -0,0 +1,42 @@
+"""unsubscription_workflow
+
+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.types import Enum
+from mailman.interfaces.mailinglist import SubscriptionPolicy
+
+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))
+
+ # 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(
+ {'unsubscription_policy':
+ op.inline_literal(SubscriptionPolicy.open)}))
+
+
+def downgrade():
+ if not is_sqlite(op.get_bind()):
+ # SQLite does not support dropping columns.
+ op.drop_column('mailinglist', 'unsubscription_policy')