Diff of /scripts/migrations/003-migrate_project_roles.py [000000] .. [3f2897]  Maximize  Restore

Switch to side-by-side view

--- a
+++ b/scripts/migrations/003-migrate_project_roles.py
@@ -0,0 +1,27 @@
+'''Merge all the OldProjectRole collections in various project databases into a
+central ProjectRole collection.
+'''
+import logging
+
+from pylons import c
+
+from ming.orm import session, state
+from allura import model as M
+
+log = logging.getLogger(__name__)
+
+seen_databases = set()
+projects = M.Project.query.find().all()
+
+for p in projects:
+    if p.database_uri in seen_databases:
+        continue
+    seen_databases.add(p.database_uri)
+    log.info('Moving project roles in database %s to main DB',
+             p.database_uri)
+    c.project = p
+    for opr in M.OldProjectRole.query.find():
+        pr = M.ProjectRole(**state(opr).document)
+    session(opr).clear()
+    session(pr).flush()
+    session(pr).clear()

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks