summaryrefslogtreecommitdiff
path: root/src/mailman/database
diff options
context:
space:
mode:
authorBarry Warsaw2012-04-08 19:40:38 -0400
committerBarry Warsaw2012-04-08 19:40:38 -0400
commitfdfc98239de2cfdfff6c62a5bb9d49abc8d3722e (patch)
tree15944f47693c8dbf3fd80292112d5f9d1ccac4d5 /src/mailman/database
parent2410fe8c2578fbd11275cfc7fc1897173eecd41a (diff)
downloadmailman-fdfc98239de2cfdfff6c62a5bb9d49abc8d3722e.tar.gz
mailman-fdfc98239de2cfdfff6c62a5bb9d49abc8d3722e.tar.zst
mailman-fdfc98239de2cfdfff6c62a5bb9d49abc8d3722e.zip
- Rename the model attributes.
- news_moderation -> newsgroup_moderation
Diffstat (limited to 'src/mailman/database')
-rw-r--r--src/mailman/database/schema/mm_20120407000000.py14
-rw-r--r--src/mailman/database/schema/sqlite_20120407000000_01.sql5
-rw-r--r--src/mailman/database/tests/test_migrations.py10
3 files changed, 14 insertions, 15 deletions
diff --git a/src/mailman/database/schema/mm_20120407000000.py b/src/mailman/database/schema/mm_20120407000000.py
index 84c563d45..bfeb1060b 100644
--- a/src/mailman/database/schema/mm_20120407000000.py
+++ b/src/mailman/database/schema/mm_20120407000000.py
@@ -48,10 +48,10 @@ def upgrade_sqlite(database, store, version, module_path):
database.load_schema(
store, version, 'sqlite_{0}_01.sql'.format(version), module_path)
results = store.execute(
- 'select id, news_prefix_subject_too, archive, archive_private '
- 'from mailinglist;')
+ 'select id, news_prefix_subject_too, news_moderation, '
+ 'archive, archive_private from mailinglist;')
for value in results:
- id, news_prefix, archive, archive_private = value
+ id, news_prefix, news_moderation, archive, archive_private = value
# Figure out what the new archive_policy column value should be.
if archive == 0:
archive_policy = int(ArchivePolicy.never)
@@ -61,8 +61,10 @@ def upgrade_sqlite(database, store, version, module_path):
archive_policy = int(ArchivePolicy.public)
store.execute(
'update ml_backup set '
- ' nntp_prefix_subject_too = {0}, '
- ' archive_policy = {1} '
- 'where id = {2};'.format(news_prefix, archive_policy, id))
+ ' nntp_moderation = {0}, '
+ ' nntp_prefix_subject_too = {1}, '
+ ' archive_policy = {2} '
+ 'where id = {2};'.format(news_moderation, news_prefix,
+ archive_policy, id))
store.execute('drop table mailinglist;')
store.execute('alter table ml_backup rename to mailinglist;')
diff --git a/src/mailman/database/schema/sqlite_20120407000000_01.sql b/src/mailman/database/schema/sqlite_20120407000000_01.sql
index 4fae9ed9d..58201fb9b 100644
--- a/src/mailman/database/schema/sqlite_20120407000000_01.sql
+++ b/src/mailman/database/schema/sqlite_20120407000000_01.sql
@@ -10,11 +10,13 @@
-- REM archive
-- REM archive_private
-- REM archive_volume_frequency
+-- REM news_moderation
-- REM news_prefix_subject_too
-- REM nntp_host
--
-- THESE COLUMNS ARE ADDED BY THE PYTHON MIGRATION LAYER:
-- ADD archive_policy
+-- ADD newsgroup_moderation
-- ADD nntp_prefix_subject_too
-- LP: #971013
@@ -95,7 +97,6 @@ CREATE TABLE ml_backup(
mime_is_default_digest BOOLEAN,
moderator_password TEXT,
new_member_options INTEGER,
- news_moderation INTEGER,
nondigestable BOOLEAN,
nonmember_rejection_notice TEXT,
obscure_addresses BOOLEAN,
@@ -206,7 +207,6 @@ INSERT INTO ml_backup SELECT
mime_is_default_digest,
moderator_password,
new_member_options,
- news_moderation,
nondigestable,
nonmember_rejection_notice,
obscure_addresses,
@@ -241,3 +241,4 @@ INSERT INTO ml_backup SELECT
-- Add the new columns. They'll get inserted at the Python layer.
ALTER TABLE ml_backup ADD COLUMN archive_policy INTEGER;
ALTER TABLE ml_backup ADD COLUMN nntp_prefix_subject_too INTEGER;
+ALTER TABLE ml_backup ADD COLUMN newsgroup_moderation INTEGER;
diff --git a/src/mailman/database/tests/test_migrations.py b/src/mailman/database/tests/test_migrations.py
index 9800a7bd7..5333083f2 100644
--- a/src/mailman/database/tests/test_migrations.py
+++ b/src/mailman/database/tests/test_migrations.py
@@ -48,6 +48,7 @@ class TestMigration20120407(unittest.TestCase):
Circa: 3.0b1 -> 3.0b2
table mailinglist:
+ * news_moderation -> newsgroup_moderation
* news_prefix_subject_too -> nntp_prefix_subject_too
* ADD archive_policy
* REMOVE archive
@@ -90,6 +91,7 @@ class TestMigration20120407(unittest.TestCase):
for present in ('archive',
'archive_private',
'archive_volume_frequency',
+ 'news_moderation',
'news_prefix_subject_too',
'nntp_host'):
# This should not produce an exception. Is there some better test
@@ -106,13 +108,6 @@ class TestMigration20120407(unittest.TestCase):
database.initialize()
# Load all the database SQL to just before ours.
database.load_migrations('20120406999999')
- # Populate the test database with a domain and a mailing list.
- with temporary_db(database):
- getUtility(IDomainManager).add(
- 'example.com', 'An example domain.',
- 'http://lists.example.com', 'postmaster@example.com')
- mlist = create_list('test@example.com')
- del mlist
database.commit()
# Load all migrations, up to and including this one.
database.load_migrations('20120407000000')
@@ -126,6 +121,7 @@ class TestMigration20120407(unittest.TestCase):
for missing in ('archive',
'archive_private',
'archive_volume_frequency',
+ 'news_moderation',
'news_prefix_subject_too',
'nntp_host'):
self.assertRaises(sqlite3.OperationalError,