~launchpad-pqm/launchpad/devel

7675.829.2 by Bryce Harrington
Add tables for tracking components in upstream bug trackers
1
-- Copyright 2010 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
CREATE TABLE BugTrackerComponentGroup (
7
    id serial PRIMARY KEY,
8
    name text NOT NULL,
7675.837.25 by Bryce Harrington
Export component_groups instead of a getAllRemoteComponentGroups() method
9
    bug_tracker integer NOT NULL REFERENCES BugTracker,
7675.829.12 by Bryce Harrington
Review by lifeless - add name constraints, clarify field comments
10
11
    CONSTRAINT valid_name CHECK (valid_name(name))
7675.829.2 by Bryce Harrington
Add tables for tracking components in upstream bug trackers
12
);
13
7675.829.14 by Bryce Harrington
Review by stub: Correct constraints and references
14
ALTER TABLE BugTrackerComponentGroup
15
    ADD CONSTRAINT bugtrackercomponentgroup__bug_tracker__name__key
16
    UNIQUE (bug_tracker, name);
17
7675.829.5 by Bryce Harrington
Finish up patch sql file to add the component and component group tables.
18
19
CREATE TABLE BugTrackerComponent (
20
    id serial PRIMARY KEY,
21
    name text NOT NULL,
7675.829.15 by Bryce Harrington
Review by stub - is_visible would be more consistent with nomenclature
22
    is_visible boolean NOT NULL DEFAULT True,
7675.829.14 by Bryce Harrington
Review by stub: Correct constraints and references
23
    is_custom boolean NOT NULL DEFAULT True,
7675.829.8 by Bryce Harrington
gmb review: field names should follow PEP8 convention
24
    component_group integer NOT NULL REFERENCES BugTrackerComponentGroup,
7675.829.12 by Bryce Harrington
Review by lifeless - add name constraints, clarify field comments
25
    distro_source_package integer REFERENCES DistributionSourcePackage,
26
27
    CONSTRAINT valid_name CHECK (valid_name(name))
7675.829.5 by Bryce Harrington
Finish up patch sql file to add the component and component group tables.
28
);
29
7675.829.14 by Bryce Harrington
Review by stub: Correct constraints and references
30
ALTER TABLE BugTrackerComponent
31
    ADD CONSTRAINT bugtrackercomponent__component_group__name__key
32
    UNIQUE (component_group, name);
33
34
ALTER TABLE BugTrackerComponent
7675.829.17 by Bryce Harrington
Also update source_package in constraint
35
    ADD CONSTRAINT bugtrackercomponent__distro_source_package__key
36
    UNIQUE (distro_source_package);
7675.829.14 by Bryce Harrington
Review by stub: Correct constraints and references
37
38
INSERT INTO LaunchpadDatabaseRevision VALUES(2208, 09, 0);