8687.15.9
by Karl Fogel
Add the copyright header block to more files (everything under database/). |
1 |
-- Copyright 2009 Canonical Ltd. This software is licensed under the
|
2 |
-- GNU Affero General Public License version 3 (see the file LICENSE).
|
|
3 |
||
7658.3.18
by Stuart Bishop
Work in progress affiliations db patch |
4 |
SET client_min_messages=ERROR; |
5 |
||
6 |
CREATE TABLE AffiliationDescription ( |
|
7 |
id serial PRIMARY KEY, |
|
8 |
pillar_name integer NOT NULL REFERENCES PillarName, |
|
9 |
sort_order integer NOT NULL DEFAULT 0, |
|
10 |
description TEXT NOT NULL, |
|
11 |
date_created timestamp WITHOUT TIME ZONE |
|
12 |
DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), |
|
13 |
||
14 |
-- UNIQUE constraint for Affiliation -> Description foreign key
|
|
15 |
CONSTRAINT affiliationdescription__pillar_name__id__key |
|
16 |
UNIQUE (pillar_name, id) |
|
17 |
);
|
|
18 |
||
19 |
CREATE TABLE PersonAffiliation ( |
|
20 |
id serial PRIMARY KEY, |
|
21 |
person integer NOT NULL REFERENCES Person, |
|
22 |
pillar_name integer NOT NULL, |
|
23 |
description integer NOT NULL, |
|
24 |
date_created timestamp WITHOUT TIME ZONE |
|
25 |
DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), |
|
26 |
status integer NOT NULL, |
|
27 |
date_status_set timestamp WITHOUT TIME ZONE |
|
28 |
DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), |
|
29 |
registrant integer NOT NULL References Person, |
|
30 |
||
31 |
CONSTRAINT personaffiliation__pillar_name__description__fk |
|
32 |
FOREIGN KEY(pillar_name, description) |
|
33 |
REFERENCES AffiliationDescription(pillar_name, id) |
|
34 |
);
|
|
35 |
||
36 |
-- Trigger to maintain date_status_set
|
|
37 |
CREATE TRIGGER set_date_set_t BEFORE UPDATE ON PersonAffiliation |
|
38 |
FOR EACH ROW EXECUTE PROCEDURE set_date_status_set(); |
|
39 |
||
40 |
-- Indexes required for person merge and looking up affiliations for a person
|
|
41 |
CREATE INDEX personaffiliation__person__idx ON PersonAffiliation(person); |
|
42 |
CREATE INDEX personaffiliation__registrant__idx |
|
43 |
ON PersonAffiliation(registrant); |
|
44 |
||
45 |
INSERT INTO LaunchpadDatabaseRevision VALUES (2109, 27, 0); |
|
46 |