diff options
| author | Barry Warsaw | 2013-10-24 20:38:39 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2013-10-24 20:38:39 -0400 |
| commit | b4d3a036b5949c6945b13416615cfd356a327ee2 (patch) | |
| tree | 005fb17df2571caba1a706e4ffd30511083e633b /src/mailman/database/schema/mm_20121015000000.py | |
| parent | d370397e38f6357612811ba55af7fdee4552b59e (diff) | |
| parent | b36b316a74cf06affbd709b3a3f3a3cfac6921c0 (diff) | |
| download | mailman-b4d3a036b5949c6945b13416615cfd356a327ee2.tar.gz mailman-b4d3a036b5949c6945b13416615cfd356a327ee2.tar.zst mailman-b4d3a036b5949c6945b13416615cfd356a327ee2.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;') |
