Merge lp:~lifeless/launchpad/bugmessage into lp:launchpad/db-devel

Proposed by Robert Collins on 2010-09-16
Status: Merged
Approved by: Stuart Bishop on 2010-09-16
Approved revision: no longer in the source branch.
Merged at revision: 9790
Proposed branch: lp:~lifeless/launchpad/bugmessage
Merge into: lp:launchpad/db-devel
Diff against target: 46 lines (+15/-1)
3 files modified
database/schema/comments.sql (+4/-1)
database/schema/patch-2208-14-0.sql (+9/-0)
lib/lp/bugs/model/bugmessage.py (+2/-0)
To merge this branch: bzr merge lp:~lifeless/launchpad/bugmessage
Reviewer Review Type Date Requested Status
Stuart Bishop db 2010-09-16 Approve on 2010-09-16
Launchpad code reviewers 2010-09-16 Pending
Review via email: mp+35620@code.launchpad.net

Commit Message

Permit getting bug message indices from the DB in the future.

Description of the Change

Permit future improvements to all bug pages that show messages or attachments by removing a current rather crazy runtime analysis for message sequence.

To post a comment you must log in.
Stuart Bishop (stub) wrote :

This version adds a unique constraint rather than a unique index, which I prefer as it puts a little more metadata into PG.

SET client_min_messages=ERROR;
ALTER TABLE BugMessage ADD COLUMN index integer;
ALTER TABLE BugMessage ADD CONSTRAINT bugmessage__bug__index__key UNIQUE (bug, index);
INSERT INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 14, 0);

As discussed, we need to populate this after the rollout and then land a followup patch setting the column NOT NULL.

review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/schema/comments.sql'
2--- database/schema/comments.sql 2010-09-13 09:14:47 +0000
3+++ database/schema/comments.sql 2010-09-16 07:03:45 +0000
4@@ -1292,11 +1292,14 @@
5
6 COMMENT ON TABLE ProjectBounty IS 'This table records a simple link between a bounty and a project. This bounty will be listed on the project web page, and the project will be mentioned on the bounty web page.';
7
8--- Messaging subsytem
9+-- BugMessages
10 COMMENT ON TABLE BugMessage IS 'This table maps a message to a bug. In other words, it shows that a particular message is associated with a particular bug.';
11 COMMENT ON COLUMN BugMessage.bugwatch IS 'The external bug this bug comment was imported from.';
12 COMMENT ON COLUMN BugMessage.remote_comment_id IS 'The id this bug comment has in the external bug tracker, if it is an imported comment. If it is NULL while having a bugwatch set, this comment was added in Launchpad and needs to be pushed to the external bug tracker.';
13 COMMENT ON COLUMN BugMessage.visible IS 'If false, the bug comment is hidden and should not be shown in any UI.';
14+COMMENT ON COLUMN BugMessage.index IS 'The index (used in urls) of the message in a particular bug.';
15+
16+-- Messaging subsytem
17 COMMENT ON TABLE Message IS 'This table stores a single RFC822-style message. Messages can be threaded (using the parent field). These messages can then be referenced from elsewhere in the system, such as the BugMessage table, integrating messageboard facilities with the rest of The Launchpad.';
18 COMMENT ON COLUMN Message.parent IS 'A "parent message". This allows for some level of threading in Messages.';
19 COMMENT ON COLUMN Message.subject IS 'The title text of the message, or the subject if it was an email.';
20
21=== added file 'database/schema/patch-2208-14-0.sql'
22--- database/schema/patch-2208-14-0.sql 1970-01-01 00:00:00 +0000
23+++ database/schema/patch-2208-14-0.sql 2010-09-16 07:03:45 +0000
24@@ -0,0 +1,9 @@
25+SET client_min_messages=ERROR;
26+
27+-- Store the row index of bug messages so we don't have to calculate it all the time.
28+ALTER TABLE BugMessage ADD COLUMN index integer;
29+
30+-- BugMessage.indexes must be unique per bug.
31+ALTER TABLE BugMessage ADD CONSTRAINT bugmessage__bug__index__key UNIQUE (bug, index);
32+
33+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 14, 0);
34
35=== modified file 'lib/lp/bugs/model/bugmessage.py'
36--- lib/lp/bugs/model/bugmessage.py 2010-08-20 20:31:18 +0000
37+++ lib/lp/bugs/model/bugmessage.py 2010-09-16 07:03:45 +0000
38@@ -44,6 +44,8 @@
39 notNull=False, default=None)
40 remote_comment_id = StringCol(notNull=False, default=None)
41 visible = BoolCol(notNull=True, default=True)
42+ # -- Uncomment when deployed.
43+ # index = IntCol()
44
45
46 class BugMessageSet:

Subscribers

People subscribed via source and target branches

to status/vote changes: