diff options
| author | Barry Warsaw | 2013-09-01 11:15:08 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2013-09-01 11:15:08 -0400 |
| commit | d146f14b3eef9f608c0e03347c135062bade8ced (patch) | |
| tree | 5a1f2f576dd7d5dcce4d6903df5cc4b6cb754815 /src/mailman/database/schema/mm_20121015000000.py | |
| parent | 41059ed20ec668baf41cceaf539f8017171e9651 (diff) | |
| download | mailman-d146f14b3eef9f608c0e03347c135062bade8ced.tar.gz mailman-d146f14b3eef9f608c0e03347c135062bade8ced.tar.zst mailman-d146f14b3eef9f608c0e03347c135062bade8ced.zip | |
Diffstat (limited to 'src/mailman/database/schema/mm_20121015000000.py')
| -rw-r--r-- | src/mailman/database/schema/mm_20121015000000.py | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/mailman/database/schema/mm_20121015000000.py b/src/mailman/database/schema/mm_20121015000000.py index 09078901d..da3671998 100644 --- a/src/mailman/database/schema/mm_20121015000000.py +++ b/src/mailman/database/schema/mm_20121015000000.py @@ -33,6 +33,9 @@ __all__ = [ ] +from mailman.database.schema.helpers import make_listid, pivot + + VERSION = '20121015000000' @@ -45,19 +48,9 @@ def upgrade(database, store, version, module_path): -def _make_listid(fqdn_listname): - list_name, at, mail_host = fqdn_listname.partition('@') - if at == '': - # If there is no @ sign in the value, assume it already contains the - # list-id. - return fqdn_listname - return '{0}.{1}'.format(list_name, mail_host) - - - def upgrade_sqlite(database, store, version, module_path): database.load_schema( - store, version, 'sqlite_{0}_01.sql'.format(version), module_path) + store, version, 'sqlite_{}_01.sql'.format(version), module_path) results = store.execute(""" SELECT id, mailing_list FROM ban; @@ -67,15 +60,12 @@ def upgrade_sqlite(database, store, version, module_path): if mailing_list is None: continue store.execute(""" - UPDATE ban_backup SET list_id = '{0}' - WHERE id = {1}; - """.format(_make_listid(mailing_list), id)) + UPDATE ban_backup SET list_id = '{}' + WHERE id = {}; + """.format(make_listid(mailing_list), id)) # Pivot the bans backup table to the real thing. - store.execute('DROP TABLE ban;') - store.execute('ALTER TABLE ban_backup RENAME TO ban;') - # Pivot the mailinglist backup table to the real thing. - store.execute('DROP TABLE mailinglist;') - store.execute('ALTER TABLE ml_backup RENAME TO mailinglist;') + pivot(store, 'ban') + pivot(store, 'mailinglist') @@ -90,7 +80,7 @@ def upgrade_postgres(database, store, version, module_path): store.execute(""" UPDATE ban SET list_id = '{0}' WHERE id = {1}; - """.format(_make_listid(mailing_list), id)) + """.format(make_listid(mailing_list), id)) store.execute('ALTER TABLE ban DROP COLUMN mailing_list;') store.execute('ALTER TABLE mailinglist DROP COLUMN new_member_options;') store.execute('ALTER TABLE mailinglist DROP COLUMN send_reminders;') |
