summaryrefslogtreecommitdiff
path: root/src/mailman/database/alembic/versions
diff options
context:
space:
mode:
authorAurélien Bompard2016-02-02 11:49:00 +0100
committerBarry Warsaw2016-02-29 21:52:13 -0500
commit15238cb5683eb9a0eab9dcd251f509a693a22451 (patch)
treeb57d661d1a6f2b1ff4b8c6920d898c36aa016164 /src/mailman/database/alembic/versions
parent14dbe7fb4a6b29ce955fa1c8d4c1859c514e8e13 (diff)
downloadmailman-15238cb5683eb9a0eab9dcd251f509a693a22451.tar.gz
mailman-15238cb5683eb9a0eab9dcd251f509a693a22451.tar.zst
mailman-15238cb5683eb9a0eab9dcd251f509a693a22451.zip
The order of a mailing list's header matches is significant
Add a numerical index property to HeaderMatch objects, and change the HeaderMatchSet manager to take the order into account. Items can now be inserted and removed by index.
Diffstat (limited to 'src/mailman/database/alembic/versions')
-rw-r--r--src/mailman/database/alembic/versions/d4fbb4fd34ca_header_match_order.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/mailman/database/alembic/versions/d4fbb4fd34ca_header_match_order.py b/src/mailman/database/alembic/versions/d4fbb4fd34ca_header_match_order.py
new file mode 100644
index 000000000..00064bc1e
--- /dev/null
+++ b/src/mailman/database/alembic/versions/d4fbb4fd34ca_header_match_order.py
@@ -0,0 +1,40 @@
+"""Add a numerical index to sort header matches.
+
+Revision ID: d4fbb4fd34ca
+Revises: bfda02ab3a9b
+Create Date: 2016-02-01 15:57:09.807678
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'd4fbb4fd34ca'
+down_revision = 'bfda02ab3a9b'
+
+import sqlalchemy as sa
+from alembic import op
+from mailman.database.helpers import is_sqlite
+
+
+def upgrade():
+ op.add_column(
+ 'headermatch', sa.Column('index', sa.Integer(), nullable=True))
+ if not is_sqlite(op.get_bind()):
+ op.alter_column(
+ 'headermatch', 'mailing_list_id',
+ existing_type=sa.INTEGER(), nullable=False)
+ op.create_index(
+ op.f('ix_headermatch_index'), 'headermatch', ['index'], unique=False)
+ op.create_index(
+ op.f('ix_headermatch_mailing_list_id'), 'headermatch',
+ ['mailing_list_id'], unique=False)
+
+
+def downgrade():
+ op.drop_index(
+ op.f('ix_headermatch_mailing_list_id'), table_name='headermatch')
+ op.drop_index(op.f('ix_headermatch_index'), table_name='headermatch')
+ if not is_sqlite(op.get_bind()):
+ op.alter_column(
+ 'headermatch', 'mailing_list_id',
+ existing_type=sa.INTEGER(), nullable=True)
+ op.drop_column('headermatch', 'index')