summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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":