Aurélien Bompard has proposed merging lp:~abompard/mailman/pgsql_upgrade into 
lp:mailman.

Requested reviews:
  Mailman Coders (mailman-coders)

For more details, see:
https://code.launchpad.net/~abompard/mailman/pgsql_upgrade/+merge/227289

As explained on 
http://www.mail-archive.com/mailman-developers%40python.org/msg14659.html, the 
schema upgrade of 20130406 is missing the PostgreSQL part. This branch adds it 
in a new migration.
-- 
https://code.launchpad.net/~abompard/mailman/pgsql_upgrade/+merge/227289
Your team Mailman Coders is requested to review the proposed merge of 
lp:~abompard/mailman/pgsql_upgrade into lp:mailman.
=== added file 'src/mailman/database/schema/mm_20140715000000.py'
--- src/mailman/database/schema/mm_20140715000000.py	1970-01-01 00:00:00 +0000
+++ src/mailman/database/schema/mm_20140715000000.py	2014-07-18 08:25:19 +0000
@@ -0,0 +1,84 @@
+# Copyright (C) 2012-2014 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.
+
+"""3.0b3 -> 3.0b4 schema migrations for PostgreSQL.
+
+* Renames:
+ - bounceevent.list_name -> bounceevent.list_id
+
+* Added:
+ - listarchiver table
+"""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+    'upgrade',
+    ]
+
+
+from mailman.database.schema.helpers import make_listid
+
+
+VERSION = '20140715000000'
+
+
+
+def upgrade(database, store, version, module_path):
+    if database.TAG == 'sqlite':
+        upgrade_sqlite(database, store, version, module_path)
+    else:
+        upgrade_postgres(database, store, version, module_path)
+
+
+
+def upgrade_sqlite(database, store, version, module_path):
+    pass # done with 20130406000000
+
+
+def upgrade_postgres(database, store, version, module_path):
+    # Rename bounceevent.list_name to list_id
+    store.execute("""
+        ALTER TABLE bounceevent
+           RENAME COLUMN list_name TO list_id;
+        """)
+    results = store.execute("""
+        SELECT id, list_id
+        FROM bounceevent;
+        """)
+    for id, list_name in results:
+        store.execute("""
+            UPDATE bounceevent SET list_id = '{}'
+            WHERE id = {};
+            """.format(make_listid(list_name), id))
+    # Create listarchiver table
+    store.execute("""
+        CREATE TABLE listarchiver (
+            id SERIAL NOT NULL,
+            mailing_list_id INTEGER NOT NULL,
+            name TEXT NOT NULL,
+            _is_enabled BOOLEAN,
+            PRIMARY KEY (id)
+            );
+        """)
+    store.execute("""
+        CREATE INDEX ix_listarchiver_mailing_list_id
+            ON listarchiver(mailing_list_id);
+        """)
+    # Record the migration in the version table.
+    database.load_schema(store, version, None, module_path)

_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to