]> git.decadent.org.uk Git - dak.git/blob - setup/init_pool.sql
Add "name" field to uid table, populate it from ldap
[dak.git] / setup / init_pool.sql
1 DROP DATABASE projectb;
2 CREATE DATABASE projectb WITH ENCODING = 'SQL_ASCII';
3
4 \c projectb
5
6 CREATE TABLE archive (
7        id SERIAL PRIMARY KEY,
8        name TEXT UNIQUE NOT NULL,
9        origin_server TEXT,
10        description TEXT
11 );
12
13 CREATE TABLE component (
14        id SERIAL PRIMARY KEY,
15        name TEXT UNIQUE NOT NULL,
16        description TEXT,
17        meets_dfsg BOOLEAN
18 );
19
20 CREATE TABLE architecture (
21        id SERIAL PRIMARY KEY,
22        arch_string TEXT UNIQUE NOT NULL,
23        description TEXT
24 );
25
26 CREATE TABLE maintainer (
27        id SERIAL PRIMARY KEY,
28        name TEXT UNIQUE NOT NULL
29 );
30
31 CREATE TABLE uid (
32        id SERIAL PRIMARY KEY,
33        uid TEXT UNIQUE NOT NULL,
34        name TEXT
35 );
36
37 CREATE TABLE fingerprint (
38        id SERIAL PRIMARY KEY,
39        fingerprint TEXT UNIQUE NOT NULL,
40        uid INT4 REFERENCES uid
41 );
42
43 CREATE TABLE location (
44        id SERIAL PRIMARY KEY,
45        path TEXT NOT NULL,
46        component INT4 REFERENCES component,
47        archive INT4 REFERENCES archive,
48        type TEXT NOT NULL
49 );
50
51 -- No references below here to allow sane population; added post-population
52
53 CREATE TABLE files (
54        id SERIAL PRIMARY KEY,
55        filename TEXT NOT NULL,
56        size INT8 NOT NULL,
57        md5sum TEXT NOT NULL,
58        location INT4 NOT NULL, -- REFERENCES location
59        last_used TIMESTAMP,
60        unique (filename, location)
61 );
62
63 CREATE TABLE source (
64         id SERIAL PRIMARY KEY,
65         source TEXT NOT NULL,
66         version TEXT NOT NULL,
67         maintainer INT4 NOT NULL, -- REFERENCES maintainer
68         file INT4 UNIQUE NOT NULL, -- REFERENCES files
69         install_date TIMESTAMP NOT NULL,
70         sig_fpr INT4 NOT NULL, -- REFERENCES fingerprint
71         unique (source, version)
72 );
73
74 CREATE TABLE dsc_files (
75        id SERIAL PRIMARY KEY,
76        source INT4 NOT NULL, -- REFERENCES source,
77        file INT4 NOT NULL, -- RERENCES files
78        unique (source, file)
79 );
80
81 CREATE TABLE binaries (
82        id SERIAL PRIMARY KEY,
83        package TEXT NOT NULL,
84        version TEXT NOT NULL,
85        maintainer INT4 NOT NULL, -- REFERENCES maintainer
86        source INT4, -- REFERENCES source,
87        architecture INT4 NOT NULL, -- REFERENCES architecture
88        file INT4 UNIQUE NOT NULL, -- REFERENCES files,
89        type TEXT NOT NULL,
90 -- joeyh@ doesn't want .udebs and .debs with the same name, which is why the unique () doesn't mention type
91        sig_fpr INT4 NOT NULL, -- REFERENCES fingerprint
92        unique (package, version, architecture)
93 );
94
95 CREATE TABLE suite (
96        id SERIAL PRIMARY KEY,
97        suite_name TEXT NOT NULL,
98        version TEXT,
99        origin TEXT,
100        label TEXT,
101        policy_engine TEXT,
102        description TEXT
103 );
104
105 CREATE TABLE queue (
106        id SERIAL PRIMARY KEY,
107        queue_name TEXT NOT NULL
108 );
109
110 CREATE TABLE suite_architectures (
111        suite INT4 NOT NULL, -- REFERENCES suite
112        architecture INT4 NOT NULL, -- REFERENCES architecture
113        unique (suite, architecture)
114 );
115
116 CREATE TABLE bin_associations (
117        id SERIAL PRIMARY KEY,
118        suite INT4 NOT NULL, -- REFERENCES suite
119        bin INT4 NOT NULL, -- REFERENCES binaries
120        unique (suite, bin)
121 );
122
123 CREATE TABLE src_associations (
124        id SERIAL PRIMARY KEY,
125        suite INT4 NOT NULL, -- REFERENCES suite
126        source INT4 NOT NULL, -- REFERENCES source
127        unique (suite, source)
128 );
129
130 CREATE TABLE section (
131        id SERIAL PRIMARY KEY,
132        section TEXT UNIQUE NOT NULL
133 );
134
135 CREATE TABLE priority (
136        id SERIAL PRIMARY KEY,
137        priority TEXT UNIQUE NOT NULL,
138        level INT4 UNIQUE NOT NULL
139 );
140
141 CREATE TABLE override_type (
142        id SERIAL PRIMARY KEY,
143        type TEXT UNIQUE NOT NULL
144 );
145
146 CREATE TABLE override (
147        package TEXT NOT NULL,
148        suite INT4 NOT NULL, -- references suite
149        component INT4 NOT NULL, -- references component
150        priority INT4, -- references priority
151        section INT4 NOT NULL, -- references section
152        type INT4 NOT NULL, -- references override_type
153        maintainer TEXT,
154        unique (suite, component, package, type)
155 );
156
157 CREATE TABLE queue_build (
158        suite INT4 NOT NULL, -- references suite
159        queue INT4 NOT NULL, -- references queue
160        filename TEXT NOT NULL,
161        in_queue BOOLEAN NOT NULL,
162        last_used TIMESTAMP
163 );
164
165 -- Critical indexes
166
167 CREATE INDEX bin_associations_bin ON bin_associations (bin);
168 CREATE INDEX src_associations_source ON src_associations (source);
169 CREATE INDEX source_maintainer ON source (maintainer);
170 CREATE INDEX binaries_maintainer ON binaries (maintainer);
171 CREATE INDEX binaries_fingerprint on binaries (sig_fpr);
172 CREATE INDEX source_fingerprint on source (sig_fpr);
173 CREATE INDEX dsc_files_file ON dsc_files (file);