~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to database/schema/patch-2208-70-0.sql

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
-- A table to store bug mutes in.
 
7
 
 
8
CREATE TABLE BugMute (
 
9
    person integer REFERENCES Person(id)
 
10
        ON DELETE CASCADE NOT NULL,
 
11
    bug integer REFERENCES Bug(id)
 
12
        ON DELETE CASCADE NOT NULL,
 
13
    date_created timestamp without time zone
 
14
        DEFAULT timezone('UTC'::text, now()) NOT NULL,
 
15
    CONSTRAINT bugmute_pkey PRIMARY KEY (person, bug)
 
16
);
 
17
 
 
18
-- We don't need an index on person, as the primary key index can be used
 
19
-- for those lookups. We have an index on just the bug, as the bulk of our
 
20
-- lookups will be on bugs.
 
21
CREATE INDEX bugmute__bug__idx
 
22
    ON BugMute(bug);
 
23
 
 
24
-- Migrate existing BugSubscription's with
 
25
-- bug_notification_level == NOTHING
 
26
-- to BugMute table.
 
27
INSERT INTO BugMute (person, bug, date_created)
 
28
    SELECT person, bug, date_created
 
29
        FROM BugSubscription
 
30
        WHERE bug_notification_level=10;
 
31
-- Remove 'muting' BugSubscriptions.
 
32
DELETE
 
33
    FROM BugSubscription
 
34
    WHERE bug_notification_level=10;
 
35
 
 
36
INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 70, 0);