aboutsummaryrefslogtreecommitdiffstats
path: root/db/schema_0050-add-defect-type-table.sql
blob: d65e179404a5cdea7074733da091c519e1792184 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
BEGIN;

CREATE TABLE defect_types (
    id serial not null primary key,
    body_id int references body(id) not null,
    name text not null,
    description text not null,
    extra text,
    unique(body_id, name)
);

CREATE TABLE contact_defect_types (
    id serial NOT NULL PRIMARY KEY,
    contact_id int REFERENCES contacts(id) NOT NULL,
    defect_type_id int REFERENCES defect_types(id) NOT NULL
);

ALTER TABLE problem
    ADD COLUMN defect_type_id int REFERENCES defect_types(id);

COMMIT;