summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2013-01-17 16:12:06 +0100
committerAurélien Bompard <aurelien@bompard.org>2013-01-17 16:20:16 +0100
commitd6977979e3d858c2a3cf5aeabe43c307526a2d7f (patch)
treec187f9a47c7fa860dd0e5b162b8ed710ea922a0f
parent1388d5ca9002d30686ccf91a4b769e9aae101f39 (diff)
downloadkittystore-d6977979e3d858c2a3cf5aeabe43c307526a2d7f.tar.gz
kittystore-d6977979e3d858c2a3cf5aeabe43c307526a2d7f.tar.xz
kittystore-d6977979e3d858c2a3cf5aeabe43c307526a2d7f.zip
Make patch2 compatible with the latest changes
-rw-r--r--kittystore/storm/schema/patch_2.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/kittystore/storm/schema/patch_2.py b/kittystore/storm/schema/patch_2.py
index b65dbb5..c98b3ab 100644
--- a/kittystore/storm/schema/patch_2.py
+++ b/kittystore/storm/schema/patch_2.py
@@ -18,6 +18,7 @@ SQL = {
PRIMARY KEY (list_name, thread_id)
);""",
'CREATE INDEX "ix_thread_date_active" ON "thread" (date_active);',
+ 'ALTER TABLE "list" ADD COLUMN "display_name" TEXT;',
],
"postgres": [ """
CREATE TABLE "thread" (
@@ -27,6 +28,7 @@ SQL = {
PRIMARY KEY (list_name, thread_id)
);""",
'CREATE INDEX "ix_thread_date_active" ON "thread" USING btree (date_active);',
+ 'ALTER TABLE "list" ADD COLUMN "display_name" TEXT;',
],
"mysql": [],
}
@@ -37,20 +39,23 @@ def apply(store):
dbtype = get_db_type(store)
for statement in SQL[dbtype]:
store.execute(statement)
- for email in store.find(Email, Email.in_reply_to == None):
- thread = Thread(email.list_name, email.thread_id)
+ for email in store.find(Email, Email.in_reply_to == None
+ ).values(Email.list_name, Email.thread_id):
+ list_name, thread_id = email
+ thread = Thread(list_name, thread_id)
store.add(thread)
store.flush()
- for email in store.find(Email):
+ for email in store.find(Email).values(Email.list_name, Email.thread_id):
# in case of partial imports, some threads are missing their original
# email (the one without an in-reply-to header)
+ list_name, thread_id = email
thread_count = store.find(Thread, And(
- Thread.list_name == email.list_name,
- Thread.thread_id == email.thread_id,
+ Thread.list_name == list_name,
+ Thread.thread_id == thread_id,
)).count()
if thread_count == 0:
# this email has no associated thread, create it
- thread = Thread(email.list_name, email.thread_id)
+ thread = Thread(list_name, thread_id)
store.add(thread)
store.flush()
if dbtype == "postgres":