diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-01-17 16:12:06 +0100 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-01-17 16:20:16 +0100 |
commit | d6977979e3d858c2a3cf5aeabe43c307526a2d7f (patch) | |
tree | c187f9a47c7fa860dd0e5b162b8ed710ea922a0f /kittystore | |
parent | 1388d5ca9002d30686ccf91a4b769e9aae101f39 (diff) | |
download | kittystore-d6977979e3d858c2a3cf5aeabe43c307526a2d7f.tar.gz kittystore-d6977979e3d858c2a3cf5aeabe43c307526a2d7f.tar.xz kittystore-d6977979e3d858c2a3cf5aeabe43c307526a2d7f.zip |
Make patch2 compatible with the latest changes
Diffstat (limited to 'kittystore')
-rw-r--r-- | kittystore/storm/schema/patch_2.py | 17 |
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": |