summaryrefslogtreecommitdiff
path: root/src/mailman/database
diff options
context:
space:
mode:
authorBarry Warsaw2013-11-27 15:13:10 -0500
committerBarry Warsaw2013-11-27 15:13:10 -0500
commit0ce1d7a1da2e93270acc49d4527417fa6c20a911 (patch)
treebbfa43d9f71690096ed218ca5862550a726f5994 /src/mailman/database
parentadde8bfb3f90f2d2204500bce75550fee8369bcb (diff)
parentb3ce2a4f6106fa4b2d014ab921f9b6a25b067de3 (diff)
downloadmailman-0ce1d7a1da2e93270acc49d4527417fa6c20a911.tar.gz
mailman-0ce1d7a1da2e93270acc49d4527417fa6c20a911.tar.zst
mailman-0ce1d7a1da2e93270acc49d4527417fa6c20a911.zip
Merge branch contributed by Joanna Skrzeszewska.
* Mailing lists can now individually enable or disable any archiver available site-wide. Contributed by Joanna Skrzeszewska. (LP: #1158040) Also: - IArchivers (i.e. system-wide archivers) now have an is_enabled attribute. - config.archivers now returns *all* archivers, including those that are disabled site-wide. This way, iterating over the list-specific archivers returns everything. - In the ini-file schema, make the default archiver class empty, otherwise the Prototype archiver is always enabled. - Added a `listarchiver` table to support list-specific archivers.
Diffstat (limited to 'src/mailman/database')
-rw-r--r--src/mailman/database/schema/sqlite_20130406000000_01.sql20
-rw-r--r--src/mailman/database/tests/test_migrations.py27
2 files changed, 45 insertions, 2 deletions
diff --git a/src/mailman/database/schema/sqlite_20130406000000_01.sql b/src/mailman/database/schema/sqlite_20130406000000_01.sql
index 9bdc2aae0..fe30ed247 100644
--- a/src/mailman/database/schema/sqlite_20130406000000_01.sql
+++ b/src/mailman/database/schema/sqlite_20130406000000_01.sql
@@ -6,12 +6,17 @@
-- For SQLite3 migration strategy, see
-- http://sqlite.org/faq.html#q11
--- REMOVALS from the bounceevent table:
+-- ADD listarchiver table.
+
+-- REMOVALs from the bounceevent table:
-- REM list_name
--- ADDS to the ban bounceevent table:
+-- ADDs to the bounceevent table:
-- ADD list_id
+-- ADDs to the mailinglist table:
+-- ADD archiver_id
+
CREATE TABLE bounceevent_backup (
id INTEGER NOT NULL,
email TEXT,
@@ -28,3 +33,14 @@ INSERT INTO bounceevent_backup SELECT
FROM bounceevent;
ALTER TABLE bounceevent_backup ADD COLUMN list_id TEXT;
+
+CREATE TABLE listarchiver (
+ id INTEGER NOT NULL,
+ mailing_list_id INTEGER NOT NULL,
+ name TEXT NOT NULL,
+ _is_enabled BOOLEAN,
+ PRIMARY KEY (id)
+ );
+
+CREATE INDEX ix_listarchiver_mailing_list_id
+ ON listarchiver(mailing_list_id);
diff --git a/src/mailman/database/tests/test_migrations.py b/src/mailman/database/tests/test_migrations.py
index d983f9891..44f594ba7 100644
--- a/src/mailman/database/tests/test_migrations.py
+++ b/src/mailman/database/tests/test_migrations.py
@@ -36,6 +36,7 @@ import unittest
from datetime import datetime
from operator import attrgetter
from pkg_resources import resource_string
+from sqlite3 import OperationalError
from storm.exceptions import DatabaseError
from zope.component import getUtility
@@ -65,6 +66,23 @@ class MigrationTestBase(unittest.TestCase):
def tearDown(self):
self._database._cleanup()
+ def _table_missing_present(self, migrations, missing, present):
+ """The appropriate migrations leave some tables missing and present.
+
+ :param migrations: Sequence of migrations to load.
+ :param missing: Tables which should be missing.
+ :param present: Tables which should be present.
+ """
+ for migration in migrations:
+ self._database.load_migrations(migration)
+ self._database.store.commit()
+ for table in missing:
+ self.assertRaises(OperationalError,
+ self._database.store.execute,
+ 'select * from {};'.format(table))
+ for table in present:
+ self._database.store.execute('select * from {};'.format(table))
+
def _missing_present(self, table, migrations, missing, present):
"""The appropriate migrations leave columns missing and present.
@@ -450,6 +468,15 @@ class TestMigration20130406Schema(MigrationTestBase):
('list_name',),
('list_id',))
+ def test_pre_listarchiver_table(self):
+ self._table_missing_present(['20130405999999'], ('listarchiver',), ())
+
+ def test_post_listarchiver_table(self):
+ self._table_missing_present(['20130405999999',
+ '20130406000000'],
+ (),
+ ('listarchiver',))
+
class TestMigration20130406MigratedData(MigrationTestBase):