Merge lp:~tiagosh/history-service/delete_from_thread_participants into lp:history-service

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 93
Merged at revision: 89
Proposed branch: lp:~tiagosh/history-service/delete_from_thread_participants
Merge into: lp:history-service
Diff against target: 227 lines (+11/-180)
5 files modified
.bzrignore (+1/-0)
plugins/sqlite/schema/schema.sql (+0/-179)
plugins/sqlite/schema/v4.sql (+8/-0)
plugins/sqlite/schema/version.info (+1/-1)
plugins/sqlite/sqlitehistoryplugin.qrc (+1/-0)
To merge this branch: bzr merge lp:~tiagosh/history-service/delete_from_thread_participants
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+185181@code.launchpad.net

Commit message

Remove data from thread_participants when deleting threads.

Description of the change

Remove data from thread_participants when deleting threads.

To post a comment you must log in.
90. By Tiago Salem Herrmann

revert previous commit

91. By Tiago Salem Herrmann

add trigger to remove items from the thread_participants table

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

308 + DELETE from thread_participants WHERE

just nitpicking, can you s/from/FROM/ ?

review: Needs Fixing
92. By Tiago Salem Herrmann

remove schema.sql and add it to .bzrignore

93. By Tiago Salem Herrmann

change 'from' to 'FROM'

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good and works as expected!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2013-08-14 19:57:33 +0000
3+++ .bzrignore 2013-09-12 17:56:31 +0000
4@@ -19,6 +19,7 @@
5 */moc_*
6 plugins/sqlite/*.depends
7 plugins/sqlite/qrc_*
8+plugins/sqlite/schema/schema.sql
9 */*.service
10 src/historyserviceadaptor.*
11 src/libhistoryservice.so*
12
13=== removed file 'plugins/sqlite/schema/schema.sql'
14--- plugins/sqlite/schema/schema.sql 2013-08-20 14:05:25 +0000
15+++ plugins/sqlite/schema/schema.sql 1970-01-01 00:00:00 +0000
16@@ -1,179 +0,0 @@
17-CREATE TABLE schema_version (
18- version int
19-);
20-CREATE TABLE text_event_attachments (
21- accountId varchar(255),
22- threadId varchar(255),
23- eventId varchar(255),
24- attachmentId varchar(255),
25- contentType varchar(255),
26- filePath varchar(255),
27- status tinyint
28-);
29-CREATE TABLE text_events (
30- accountId varchar(255),
31- threadId varchar(255),
32- eventId varchar(255),
33- senderId varchar(255),
34- timestamp datetime,
35- newEvent bool,
36- message varchar(512),
37- messageType tinyint,
38- messageFlags tinyint,
39- readTimestamp datetime
40-, subject varchar(256));
41-CREATE TABLE thread_participants (
42- accountId varchar(255),
43- threadId varchar(255),
44- type tinyint,
45- participantId varchar(255)
46-);
47-CREATE TABLE threads (
48- accountId varchar(255),
49- threadId varchar(255),
50- type tinyint,
51- lastEventId varchar(255),
52- lastEventTimestamp datetime,
53- count int,
54- unreadCount int
55-);
56-CREATE TABLE voice_events (
57- accountId varchar(255),
58- threadId varchar(255),
59- eventId varchar(255),
60- senderId varchar(255),
61- timestamp datetime,
62- newEvent bool,
63- duration int,
64- missed bool
65-);
66-CREATE TRIGGER text_events_delete_trigger AFTER DELETE ON text_events
67-FOR EACH ROW
68-BEGIN
69- UPDATE threads SET count=(SELECT count(eventId) FROM text_events WHERE
70- accountId=old.accountId AND
71- threadId=old.threadId)
72- WHERE accountId=old.accountId AND threadId=old.threadId AND type=0;
73- UPDATE threads SET unreadCount=(SELECT count(eventId) FROM text_events WHERE
74- accountId=old.accountId AND threadId=old.threadId AND newEvent='true')
75- WHERE accountId=old.accountId AND threadId=old.threadId AND type=0;
76- UPDATE threads SET lastEventId=(SELECT eventId FROM text_events WHERE
77- accountId=old.accountId AND
78- threadId=old.threadId
79- ORDER BY timestamp DESC LIMIT 1)
80- WHERE accountId=old.accountId AND threadId=old.threadId AND type=0;
81- UPDATE threads SET lastEventTimestamp=(SELECT timestamp FROM text_events WHERE
82- accountId=old.accountId AND
83- threadId=old.threadId
84- ORDER BY timestamp DESC LIMIT 1)
85- WHERE accountId=old.accountId AND threadId=old.threadId AND type=0;
86- DELETE from text_event_attachments WHERE
87- accountId=old.accountId AND
88- threadId=old.threadId AND
89- eventId=old.eventId;
90-END;
91-CREATE TRIGGER text_events_insert_trigger AFTER INSERT ON text_events
92-FOR EACH ROW
93-BEGIN
94- UPDATE threads SET count=(SELECT count(eventId) FROM text_events WHERE
95- accountId=new.accountId AND
96- threadId=new.threadId)
97- WHERE accountId=new.accountId AND threadId=new.threadId AND type=0;
98- UPDATE threads SET unreadCount=(SELECT count(eventId) FROM text_events WHERE
99- accountId=new.accountId AND threadId=new.threadId AND newEvent='true')
100- WHERE accountId=new.accountId AND threadId=new.threadId AND type=0;
101- UPDATE threads SET lastEventId=(SELECT eventId FROM text_events WHERE
102- accountId=new.accountId AND
103- threadId=new.threadId
104- ORDER BY timestamp DESC LIMIT 1)
105- WHERE accountId=new.accountId AND threadId=new.threadId AND type=0;
106- UPDATE threads SET lastEventTimestamp=(SELECT timestamp FROM text_events WHERE
107- accountId=new.accountId AND
108- threadId=new.threadId
109- ORDER BY timestamp DESC LIMIT 1)
110- WHERE accountId=new.accountId AND threadId=new.threadId AND type=0;
111-END;
112-CREATE TRIGGER text_events_update_trigger AFTER UPDATE ON text_events
113-FOR EACH ROW
114-BEGIN
115- UPDATE threads SET count=(SELECT count(eventId) FROM text_events WHERE
116- accountId=new.accountId AND
117- threadId=new.threadId)
118- WHERE accountId=new.accountId AND threadId=new.threadId AND type=0;
119- UPDATE threads SET unreadCount=(SELECT count(eventId) FROM text_events WHERE
120- accountId=new.accountId AND threadId=new.threadId AND newEvent='true')
121- WHERE accountId=new.accountId AND threadId=new.threadId AND type=0;
122- UPDATE threads SET lastEventId=(SELECT eventId FROM text_events WHERE
123- accountId=new.accountId AND
124- threadId=new.threadId
125- ORDER BY timestamp DESC LIMIT 1)
126- WHERE accountId=new.accountId AND threadId=new.threadId AND type=0;
127- UPDATE threads SET lastEventTimestamp=(SELECT timestamp FROM text_events WHERE
128- accountId=new.accountId AND
129- threadId=new.threadId
130- ORDER BY timestamp DESC LIMIT 1)
131- WHERE accountId=new.accountId AND threadId=new.threadId AND type=0;
132-END;
133-CREATE TRIGGER voice_events_delete_trigger AFTER DELETE ON voice_events
134-FOR EACH ROW
135-BEGIN
136- UPDATE threads SET count=(SELECT count(eventId) FROM voice_events WHERE
137- accountId=old.accountId AND
138- threadId=old.threadId)
139- WHERE accountId=old.accountId AND threadId=old.threadId AND type=1;
140- UPDATE threads SET unreadCount=(SELECT count(eventId) FROM voice_events WHERE
141- accountId=old.accountId AND threadId=old.threadId AND newEvent='true')
142- WHERE accountId=old.accountId AND threadId=old.threadId AND type=1;
143- UPDATE threads SET lastEventId=(SELECT eventId FROM voice_events WHERE
144- accountId=old.accountId AND
145- threadId=old.threadId
146- ORDER BY timestamp DESC LIMIT 1)
147- WHERE accountId=old.accountId AND threadId=old.threadId AND type=1;
148- UPDATE threads SET lastEventTimestamp=(SELECT timestamp FROM voice_events WHERE
149- accountId=old.accountId AND
150- threadId=old.threadId
151- ORDER BY timestamp DESC LIMIT 1)
152- WHERE accountId=old.accountId AND threadId=old.threadId AND type=1;
153-END;
154-CREATE TRIGGER voice_events_insert_trigger AFTER INSERT ON voice_events
155-FOR EACH ROW
156-BEGIN
157- UPDATE threads SET count=(SELECT count(eventId) FROM voice_events WHERE
158- accountId=new.accountId AND
159- threadId=new.threadId)
160- WHERE accountId=new.accountId AND threadId=new.threadId AND type=1;
161- UPDATE threads SET unreadCount=(SELECT count(eventId) FROM voice_events WHERE
162- accountId=new.accountId AND threadId=new.threadId AND newEvent='true')
163- WHERE accountId=new.accountId AND threadId=new.threadId AND type=1;
164- UPDATE threads SET lastEventId=(SELECT eventId FROM voice_events WHERE
165- accountId=new.accountId AND
166- threadId=new.threadId
167- ORDER BY timestamp DESC LIMIT 1)
168- WHERE accountId=new.accountId AND threadId=new.threadId AND type=1;
169- UPDATE threads SET lastEventTimestamp=(SELECT timestamp FROM voice_events WHERE
170- accountId=new.accountId AND
171- threadId=new.threadId
172- ORDER BY timestamp DESC LIMIT 1)
173- WHERE accountId=new.accountId AND threadId=new.threadId AND type=1;
174-END;
175-CREATE TRIGGER voice_events_update_trigger AFTER UPDATE ON voice_events
176-FOR EACH ROW
177-BEGIN
178- UPDATE threads SET count=(SELECT count(eventId) FROM voice_events WHERE
179- accountId=new.accountId AND
180- threadId=new.threadId)
181- WHERE accountId=new.accountId AND threadId=new.threadId AND type=1;
182- UPDATE threads SET unreadCount=(SELECT count(eventId) FROM voice_events WHERE
183- accountId=new.accountId AND threadId=new.threadId AND newEvent='true')
184- WHERE accountId=new.accountId AND threadId=new.threadId AND type=1;
185- UPDATE threads SET lastEventId=(SELECT eventId FROM voice_events WHERE
186- accountId=new.accountId AND
187- threadId=new.threadId
188- ORDER BY timestamp DESC LIMIT 1)
189- WHERE accountId=new.accountId AND threadId=new.threadId AND type=1;
190- UPDATE threads SET lastEventTimestamp=(SELECT timestamp FROM voice_events WHERE
191- accountId=new.accountId AND
192- threadId=new.threadId
193- ORDER BY timestamp DESC LIMIT 1)
194- WHERE accountId=new.accountId AND threadId=new.threadId AND type=1;
195-END;
196
197=== added file 'plugins/sqlite/schema/v4.sql'
198--- plugins/sqlite/schema/v4.sql 1970-01-01 00:00:00 +0000
199+++ plugins/sqlite/schema/v4.sql 2013-09-12 17:56:31 +0000
200@@ -0,0 +1,8 @@
201+CREATE TRIGGER threads_delete_trigger AFTER DELETE ON threads
202+FOR EACH ROW
203+BEGIN
204+ DELETE FROM thread_participants WHERE
205+ accountId=old.accountId AND
206+ threadId=old.threadId AND
207+ type=old.type;
208+END;
209
210=== modified file 'plugins/sqlite/schema/version.info'
211--- plugins/sqlite/schema/version.info 2013-08-20 14:05:25 +0000
212+++ plugins/sqlite/schema/version.info 2013-09-12 17:56:31 +0000
213@@ -1,1 +1,1 @@
214-3
215+4
216
217=== modified file 'plugins/sqlite/sqlitehistoryplugin.qrc'
218--- plugins/sqlite/sqlitehistoryplugin.qrc 2013-08-20 14:05:25 +0000
219+++ plugins/sqlite/sqlitehistoryplugin.qrc 2013-09-12 17:56:31 +0000
220@@ -4,6 +4,7 @@
221 <file>schema/v1.sql</file>
222 <file>schema/v2.sql</file>
223 <file>schema/v3.sql</file>
224+ <file>schema/v4.sql</file>
225 <file>schema/version.info</file>
226 </qresource>
227 </RCC>

Subscribers

People subscribed via source and target branches