Merge lp:~lifeless/launchpad/bug-421901 into lp:launchpad/db-devel

Proposed by Robert Collins
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: 10416
Proposed branch: lp:~lifeless/launchpad/bug-421901
Merge into: lp:launchpad/db-devel
Diff against target: 349 lines (+142/-76)
7 files modified
database/sampledata/current-dev.sql (+36/-36)
database/sampledata/current.sql (+36/-36)
lib/lp/bugs/interfaces/bugmessage.py (+4/-0)
lib/lp/bugs/model/bugmessage.py (+4/-0)
lib/lp/scripts/garbo.py (+32/-0)
lib/lp/scripts/tests/test_garbo.py (+21/-0)
lib/lp/testing/pgsql.py (+9/-4)
To merge this branch: bzr merge lp:~lifeless/launchpad/bug-421901
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+56861@code.launchpad.net

Commit message

[r=mwhudson][bug=421901] Add a migration task for the denormalisation into BugMessage.owner.

Description of the change

Add a migration task for the denormalisation into BugMessage.owner. This completes the work we can sensibly do until the next database downtime window.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

As discussed on IRC, for /me/ superuser_connection() is a clearer name than root_connection() ('root' is a touch overloaded and I didn't get the intent in this context).

Other than that, looks fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/sampledata/current-dev.sql'
2--- database/sampledata/current-dev.sql 2011-03-30 10:46:24 +0000
3+++ database/sampledata/current-dev.sql 2011-04-08 00:45:52 +0000
4@@ -3403,42 +3403,42 @@
5
6 ALTER TABLE bugmessage DISABLE TRIGGER ALL;
7
8-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (1, 2, 1, NULL, NULL, 0);
9-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (2, 1, 3, NULL, NULL, 0);
10-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (3, 1, 4, NULL, NULL, 1);
11-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (4, 2, 5, NULL, NULL, 1);
12-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (5, 2, 6, NULL, NULL, 2);
13-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (6, 4, 7, NULL, NULL, 0);
14-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (7, 5, 8, NULL, NULL, 0);
15-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (8, 6, 9, NULL, NULL, 0);
16-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (9, 3, 10, NULL, NULL, 0);
17-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (10, 7, 11, NULL, NULL, 0);
18-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (11, 8, 14, NULL, NULL, 0);
19-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (12, 9, 15, NULL, NULL, 0);
20-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (13, 10, 17, NULL, NULL, 0);
21-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (14, 10, 16, NULL, NULL, 1);
22-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (15, 11, 24, NULL, NULL, 0);
23-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (16, 11, 25, NULL, NULL, 1);
24-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (17, 11, 26, NULL, NULL, 2);
25-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (18, 11, 27, NULL, NULL, 3);
26-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (19, 11, 28, NULL, NULL, 4);
27-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (20, 11, 29, NULL, NULL, 5);
28-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (21, 11, 30, NULL, NULL, 6);
29-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (22, 12, 31, NULL, NULL, 0);
30-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (23, 12, 33, NULL, NULL, 1);
31-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (24, 12, 34, NULL, NULL, 2);
32-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (25, 12, 35, NULL, NULL, 3);
33-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (26, 12, 36, NULL, NULL, 4);
34-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (27, 13, 37, NULL, NULL, 0);
35-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (28, 13, 38, NULL, NULL, 1);
36-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (29, 14, 39, NULL, NULL, 0);
37-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (30, 15, 40, NULL, NULL, 0);
38-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (31, 15, 44, 11, '<4284D7D1.6010208@gmx.de>', 1);
39-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (32, 15, 45, 11, '<20050517185429.GB20786@spring.luon.net>', 2);
40-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (33, 15, 46, 11, '<428A44E9.6090802@gmx.de>', 3);
41-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (34, 15, 47, 11, '<20050517202044.GA23231@spring.luon.net>', 4);
42-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (35, 15, 48, 11, '<20050617140011.GA15638@piware.de>', 5);
43-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (36, 15, 49, 11, '<42BD2E36.9090809@gmx.de>', 6);
44+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (1, 2, 1, NULL, NULL, 0, 16);
45+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (2, 1, 3, NULL, NULL, 0, 12);
46+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (3, 1, 4, NULL, NULL, 1, 12);
47+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (4, 2, 5, NULL, NULL, 1, 12);
48+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (5, 2, 6, NULL, NULL, 2, 12);
49+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (6, 4, 7, NULL, NULL, 0, 12);
50+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (7, 5, 8, NULL, NULL, 0, 12);
51+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (8, 6, 9, NULL, NULL, 0, 12);
52+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (9, 3, 10, NULL, NULL, 0, 12);
53+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (10, 7, 11, NULL, NULL, 0, 16);
54+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (11, 8, 14, NULL, NULL, 0, 12);
55+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (12, 9, 15, NULL, NULL, 0, 16);
56+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (13, 10, 17, NULL, NULL, 0, 16);
57+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (14, 10, 16, NULL, NULL, 1, 16);
58+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (15, 11, 24, NULL, NULL, 0, 26);
59+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (16, 11, 25, NULL, NULL, 1, 50);
60+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (17, 11, 26, NULL, NULL, 2, 66);
61+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (18, 11, 27, NULL, NULL, 3, 63);
62+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (19, 11, 28, NULL, NULL, 4, 27);
63+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (20, 11, 29, NULL, NULL, 5, 33);
64+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (21, 11, 30, NULL, NULL, 6, 3);
65+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (22, 12, 31, NULL, NULL, 0, 8);
66+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (23, 12, 33, NULL, NULL, 1, 45);
67+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (24, 12, 34, NULL, NULL, 2, 13);
68+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (25, 12, 35, NULL, NULL, 3, 9);
69+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (26, 12, 36, NULL, NULL, 4, 6);
70+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (27, 13, 37, NULL, NULL, 0, 12);
71+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (28, 13, 38, NULL, NULL, 1, 12);
72+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (29, 14, 39, NULL, NULL, 0, 63);
73+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (30, 15, 40, NULL, NULL, 0, 16);
74+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (31, 15, 44, 11, '<4284D7D1.6010208@gmx.de>', 1, 243614);
75+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (32, 15, 45, 11, '<20050517185429.GB20786@spring.luon.net>', 2, 243615);
76+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (33, 15, 46, 11, '<428A44E9.6090802@gmx.de>', 3, 243614);
77+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (34, 15, 47, 11, '<20050517202044.GA23231@spring.luon.net>', 4, 243615);
78+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (35, 15, 48, 11, '<20050617140011.GA15638@piware.de>', 5, 243616);
79+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (36, 15, 49, 11, '<42BD2E36.9090809@gmx.de>', 6, 243614);
80
81
82 ALTER TABLE bugmessage ENABLE TRIGGER ALL;
83
84=== modified file 'database/sampledata/current.sql'
85--- database/sampledata/current.sql 2011-03-18 15:28:46 +0000
86+++ database/sampledata/current.sql 2011-04-08 00:45:52 +0000
87@@ -3342,42 +3342,42 @@
88
89 ALTER TABLE bugmessage DISABLE TRIGGER ALL;
90
91-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (1, 2, 1, NULL, NULL, 0);
92-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (2, 1, 3, NULL, NULL, 0);
93-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (3, 1, 4, NULL, NULL, 1);
94-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (4, 2, 5, NULL, NULL, 1);
95-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (5, 2, 6, NULL, NULL, 2);
96-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (6, 4, 7, NULL, NULL, 0);
97-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (7, 5, 8, NULL, NULL, 0);
98-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (8, 6, 9, NULL, NULL, 0);
99-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (9, 3, 10, NULL, NULL, 0);
100-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (10, 7, 11, NULL, NULL, 0);
101-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (11, 8, 14, NULL, NULL, 0);
102-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (12, 9, 15, NULL, NULL, 0);
103-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (13, 10, 17, NULL, NULL, 0);
104-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (14, 10, 16, NULL, NULL, 1);
105-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (15, 11, 24, NULL, NULL, 0);
106-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (16, 11, 25, NULL, NULL, 1);
107-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (17, 11, 26, NULL, NULL, 2);
108-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (18, 11, 27, NULL, NULL, 3);
109-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (19, 11, 28, NULL, NULL, 4);
110-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (20, 11, 29, NULL, NULL, 5);
111-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (21, 11, 30, NULL, NULL, 6);
112-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (22, 12, 31, NULL, NULL, 0);
113-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (23, 12, 33, NULL, NULL, 1);
114-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (24, 12, 34, NULL, NULL, 2);
115-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (25, 12, 35, NULL, NULL, 3);
116-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (26, 12, 36, NULL, NULL, 4);
117-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (27, 13, 37, NULL, NULL, 0);
118-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (28, 13, 38, NULL, NULL, 1);
119-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (29, 14, 39, NULL, NULL, 0);
120-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (30, 15, 40, NULL, NULL, 0);
121-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (31, 15, 44, 11, '<4284D7D1.6010208@gmx.de>', 1);
122-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (32, 15, 45, 11, '<20050517185429.GB20786@spring.luon.net>', 2);
123-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (33, 15, 46, 11, '<428A44E9.6090802@gmx.de>', 3);
124-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (34, 15, 47, 11, '<20050517202044.GA23231@spring.luon.net>', 4);
125-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (35, 15, 48, 11, '<20050617140011.GA15638@piware.de>', 5);
126-INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index) VALUES (36, 15, 49, 11, '<42BD2E36.9090809@gmx.de>', 6);
127+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (1, 2, 1, NULL, NULL, 0, 16);
128+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (2, 1, 3, NULL, NULL, 0, 12);
129+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (3, 1, 4, NULL, NULL, 1, 12);
130+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (4, 2, 5, NULL, NULL, 1, 12);
131+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (5, 2, 6, NULL, NULL, 2, 12);
132+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (6, 4, 7, NULL, NULL, 0, 12);
133+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (7, 5, 8, NULL, NULL, 0, 12);
134+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (8, 6, 9, NULL, NULL, 0, 12);
135+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (9, 3, 10, NULL, NULL, 0, 12);
136+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (10, 7, 11, NULL, NULL, 0, 16);
137+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (11, 8, 14, NULL, NULL, 0, 12);
138+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (12, 9, 15, NULL, NULL, 0, 16);
139+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (13, 10, 17, NULL, NULL, 0, 16);
140+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (14, 10, 16, NULL, NULL, 1, 16);
141+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (15, 11, 24, NULL, NULL, 0, 26);
142+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (16, 11, 25, NULL, NULL, 1, 50);
143+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (17, 11, 26, NULL, NULL, 2, 66);
144+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (18, 11, 27, NULL, NULL, 3, 63);
145+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (19, 11, 28, NULL, NULL, 4, 27);
146+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (20, 11, 29, NULL, NULL, 5, 33);
147+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (21, 11, 30, NULL, NULL, 6, 3);
148+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (22, 12, 31, NULL, NULL, 0, 8);
149+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (23, 12, 33, NULL, NULL, 1, 45);
150+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (24, 12, 34, NULL, NULL, 2, 13);
151+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (25, 12, 35, NULL, NULL, 3, 9);
152+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (26, 12, 36, NULL, NULL, 4, 6);
153+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (27, 13, 37, NULL, NULL, 0, 12);
154+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (28, 13, 38, NULL, NULL, 1, 12);
155+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (29, 14, 39, NULL, NULL, 0, 63);
156+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (30, 15, 40, NULL, NULL, 0, 16);
157+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (31, 15, 44, 11, '<4284D7D1.6010208@gmx.de>', 1, 243614);
158+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (32, 15, 45, 11, '<20050517185429.GB20786@spring.luon.net>', 2, 243615);
159+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (33, 15, 46, 11, '<428A44E9.6090802@gmx.de>', 3, 243614);
160+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (34, 15, 47, 11, '<20050517202044.GA23231@spring.luon.net>', 4, 243615);
161+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (35, 15, 48, 11, '<20050617140011.GA15638@piware.de>', 5, 243616);
162+INSERT INTO bugmessage (id, bug, message, bugwatch, remote_comment_id, index, owner) VALUES (36, 15, 49, 11, '<42BD2E36.9090809@gmx.de>', 6, 243614);
163
164
165 ALTER TABLE bugmessage ENABLE TRIGGER ALL;
166
167=== modified file 'lib/lp/bugs/interfaces/bugmessage.py'
168--- lib/lp/bugs/interfaces/bugmessage.py 2011-03-02 15:34:31 +0000
169+++ lib/lp/bugs/interfaces/bugmessage.py 2011-04-08 00:45:52 +0000
170@@ -31,6 +31,7 @@
171 from lp.app.validators.attachment import attachment_size_constraint
172 from lp.bugs.interfaces.bug import IBug
173 from lp.bugs.interfaces.bugwatch import IBugWatch
174+from lp.registry.interfaces.person import IPerson
175 from lp.services.fields import Title
176
177
178@@ -52,6 +53,9 @@
179 bugwatchID = Int(title=u'The bugwatch id.', readonly=True)
180 remote_comment_id = TextLine(
181 title=u"The id this comment has in the bugwatch's bug tracker.")
182+ ownerID = Attribute("The ID of the owner mirrored from the message")
183+ owner = Object(schema=IPerson,
184+ title=u"The Message owner mirrored from the message.", readonly=True)
185
186
187 class IBugMessageSet(Interface):
188
189=== modified file 'lib/lp/bugs/model/bugmessage.py'
190--- lib/lp/bugs/model/bugmessage.py 2011-03-02 15:34:31 +0000
191+++ lib/lp/bugs/model/bugmessage.py 2011-04-08 00:45:52 +0000
192@@ -29,6 +29,7 @@
193 IBugMessage,
194 IBugMessageSet,
195 )
196+from lp.registry.interfaces.person import validate_public_person
197
198
199 class BugMessage(SQLBase):
200@@ -46,6 +47,9 @@
201 remote_comment_id = StringCol(notNull=False, default=None)
202 # -- The index of the message is cached in the DB.
203 index = IntCol(notNull=True)
204+ # -- The owner, cached from the message table using triggers.
205+ owner = ForeignKey(dbName='owner', foreignKey='Person',
206+ storm_validator=validate_public_person, notNull=False)
207
208 def __repr__(self):
209 return "<BugMessage at 0x%x message=%s index=%s>" % (
210
211=== modified file 'lib/lp/scripts/garbo.py'
212--- lib/lp/scripts/garbo.py 2011-03-31 20:55:25 +0000
213+++ lib/lp/scripts/garbo.py 2011-04-08 00:45:52 +0000
214@@ -64,6 +64,7 @@
215 from lp.bugs.interfaces.bug import IBugSet
216 from lp.bugs.model.bug import Bug
217 from lp.bugs.model.bugattachment import BugAttachment
218+from lp.bugs.model.bugmessage import BugMessage
219 from lp.bugs.model.bugnotification import BugNotification
220 from lp.bugs.model.bugwatch import BugWatchActivity
221 from lp.bugs.scripts.checkwatches.scheduler import (
222@@ -692,6 +693,36 @@
223 """
224
225
226+class MirrorBugMessageOwner(TunableLoop):
227+ """Mirror BugMessage.owner from Message.
228+
229+ Only needed until they are all set, after that triggers will maintain it.
230+ """
231+
232+ # Test migration did 3M in 2 hours, so 5000 is ~ 10 seconds - and thats the
233+ # max we want to hold a DB lock open for.
234+ minimum_chunk_size = 1000
235+ maximum_chunk_size = 5000
236+
237+ def __init__(self, log, abort_time=None):
238+ super(MirrorBugMessageOwner, self).__init__(log, abort_time)
239+ self.store = IMasterStore(BugMessage)
240+ self.isDone = IMasterStore(BugMessage).find(
241+ BugMessage, BugMessage.ownerID==None).is_empty
242+
243+ def __call__(self, chunk_size):
244+ """See `ITunableLoop`."""
245+ transaction.begin()
246+ updated = self.store.execute("""update bugmessage set
247+ owner=message.owner from message where
248+ bugmessage.message=message.id and bugmessage.id in
249+ (select id from bugmessage where owner is NULL limit %s);"""
250+ % int(chunk_size)
251+ ).rowcount
252+ self.log.debug("Updated %s bugmessages." % updated)
253+ transaction.commit()
254+
255+
256 class BugHeatUpdater(TunableLoop):
257 """A `TunableLoop` for bug heat calculations."""
258
259@@ -1078,6 +1109,7 @@
260 class HourlyDatabaseGarbageCollector(BaseDatabaseGarbageCollector):
261 script_name = 'garbo-hourly'
262 tunable_loops = [
263+ MirrorBugMessageOwner,
264 OAuthNoncePruner,
265 OpenIDConsumerNoncePruner,
266 OpenIDConsumerAssociationPruner,
267
268=== modified file 'lib/lp/scripts/tests/test_garbo.py'
269--- lib/lp/scripts/tests/test_garbo.py 2011-03-31 20:55:25 +0000
270+++ lib/lp/scripts/tests/test_garbo.py 2011-04-08 00:45:52 +0000
271@@ -55,6 +55,7 @@
272 ZopelessDatabaseLayer,
273 )
274 from lp.archiveuploader.dscfile import findFile
275+from lp.bugs.model.bugmessage import BugMessage
276 from lp.bugs.model.bugnotification import (
277 BugNotification,
278 BugNotificationRecipient,
279@@ -932,3 +933,23 @@
280 self.assertFalse(spr.changelog == None)
281 self.assertTrue(spr.changelog.restricted)
282 self.assertEqual(changelog, spr.changelog.read())
283+
284+ def test_mirror_bugmessages(self):
285+ # Nuke the owner in sampledata.
286+ con = DatabaseLayer._db_fixture.superuser_connection()
287+ try:
288+ cur = con.cursor()
289+ cur.execute("ALTER TABLE bugmessage "
290+ "DISABLE TRIGGER bugmessage__owner__mirror")
291+ cur.execute("UPDATE bugmessage set owner=NULL")
292+ cur.execute("ALTER TABLE bugmessage "
293+ "ENABLE TRIGGER bugmessage__owner__mirror")
294+ con.commit()
295+ finally:
296+ con.close()
297+ store = IMasterStore(BugMessage)
298+ unmigrated = store.find(BugMessage, BugMessage.ownerID==None).count
299+ self.assertNotEqual(0, unmigrated())
300+ self.runHourly()
301+ self.assertEqual(0, unmigrated())
302+
303
304=== modified file 'lib/lp/testing/pgsql.py'
305--- lib/lp/testing/pgsql.py 2011-02-19 13:50:19 +0000
306+++ lib/lp/testing/pgsql.py 2011-04-08 00:45:52 +0000
307@@ -220,9 +220,14 @@
308 connection_parameters.append('port=%s' % self.host)
309 return ' '.join(connection_parameters)
310
311+ def superuser_connection(self, dbname=None):
312+ if dbname is None:
313+ dbname = self.dbname
314+ return psycopg2.connect(self._connectionString(dbname))
315+
316 def generateResetSequencesSQL(self):
317 """Return a SQL statement that resets all sequences."""
318- con = psycopg2.connect(self._connectionString(self.dbname))
319+ con = self.superuser_connection()
320 cur = con.cursor()
321 try:
322 return generateResetSequencesSQL(cur)
323@@ -243,7 +248,7 @@
324 # anyway (because they might have been incremented even if
325 # nothing was committed), making sure not to disturb the
326 # 'committed' flag, and we're done.
327- con = psycopg2.connect(self._connectionString(self.dbname))
328+ con = self.superuser_connection()
329 cur = con.cursor()
330 if self.reset_sequences_sql is None:
331 resetSequences(cur)
332@@ -261,7 +266,7 @@
333 # template database that are slow in dropping off.
334 attempts = 60
335 for counter in range(0, attempts):
336- con = psycopg2.connect(self._connectionString(self.template))
337+ con = self.superuser_connection(self.template)
338 try:
339 con.set_isolation_level(0)
340 cur = con.cursor()
341@@ -321,7 +326,7 @@
342 attempts = 100
343 for i in range(0, attempts):
344 try:
345- con = psycopg2.connect(self._connectionString(self.template))
346+ con = self.superuser_connection(self.template)
347 except psycopg2.OperationalError, x:
348 if 'does not exist' in x:
349 return

Subscribers

People subscribed via source and target branches

to status/vote changes: