7675.1132.1
by Abel Deuring
add a (redundant) column owner to QuestionMessage |
1 |
-- Copyright 2011 Canonical Ltd. This software is licensed under the
|
2 |
-- GNU Affero General Public License version 3 (see the file LICENSE).
|
|
3 |
||
4 |
SET client_min_messages=ERROR; |
|
5 |
||
6 |
-- denormalise message.owner for query efficiency.
|
|
7 |
ALTER TABLE QuestionMessage ADD COLUMN owner int; |
|
8 |
-- And an index.
|
|
9 |
CREATE INDEX questionmessage__owner__idx ON QuestionMessage(owner); |
|
10 |
||
11 |
UPDATE QuestionMessage SET owner = ( |
|
12 |
SELECT owner FROM Message WHERE Message.id=QuestionMessage.message); |
|
13 |
||
7675.1132.6
by Abel Deuring
NOT NULL Constraint again added to QuestionMessage.owner |
14 |
ALTER TABLE QuestionMessage ALTER COLUMN owner SET NOT NULL; |
15 |
||
7675.1132.1
by Abel Deuring
add a (redundant) column owner to QuestionMessage |
16 |
-- Triggers to maintain in both directions.
|
17 |
CREATE TRIGGER questionmessage__owner__mirror |
|
18 |
AFTER UPDATE OR INSERT ON questionmessage |
|
19 |
FOR EACH ROW EXECUTE PROCEDURE questionmessage_copy_owner_from_message(); |
|
20 |
CREATE TRIGGER message__owner__mirror__questionmessage AFTER UPDATE ON message |
|
21 |
FOR EACH ROW EXECUTE PROCEDURE message_copy_owner_to_questionmessage(); |
|
22 |
||
7675.1132.2
by Abel Deuring
DB patch number changed; NOT NULL constraint for QuestionMessage.owner and BugMessage.owner; sampledata updated so that the new constraints are fulfilled. |
23 |
INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 69, 0); |