1 DROP DATABASE projectb;
2 CREATE DATABASE projectb WITH ENCODING = 'SQL_ASCII';
8 name TEXT UNIQUE NOT NULL,
13 CREATE TABLE component (
14 id SERIAL PRIMARY KEY,
15 name TEXT UNIQUE NOT NULL,
20 CREATE TABLE architecture (
21 id SERIAL PRIMARY KEY,
22 arch_string TEXT UNIQUE NOT NULL,
26 CREATE TABLE maintainer (
27 id SERIAL PRIMARY KEY,
28 name TEXT UNIQUE NOT NULL
31 CREATE TABLE src_uploaders (
32 id SERIAL PRIMARY KEY,
33 source INT4 NOT NULL REFERENCES source,
34 maintainer INT4 NOT NULL REFERENCES maintainer
38 id SERIAL PRIMARY KEY,
39 uid TEXT UNIQUE NOT NULL,
43 CREATE TABLE keyrings (
44 id SERIAL PRIMARY KEY,
49 CREATE TABLE fingerprint (
50 id SERIAL PRIMARY KEY,
51 fingerprint TEXT UNIQUE NOT NULL,
52 uid INT4 REFERENCES uid,
53 keyring INT4 REFERENCES keyrings
56 CREATE TABLE location (
57 id SERIAL PRIMARY KEY,
59 component INT4 REFERENCES component,
60 archive INT4 REFERENCES archive,
64 -- No references below here to allow sane population; added post-population
67 id SERIAL PRIMARY KEY,
68 filename TEXT NOT NULL,
71 location INT4 NOT NULL, -- REFERENCES location
73 sha1sum TEXT NOT NULL,
74 sha256sum TEXT NOT NULL,
75 unique (filename, location)
79 id SERIAL PRIMARY KEY,
81 version TEXT NOT NULL,
82 maintainer INT4 NOT NULL, -- REFERENCES maintainer
83 changedby INT4 NOT NULL, -- REFERENCES maintainer
84 file INT4 UNIQUE NOT NULL, -- REFERENCES files
85 install_date TIMESTAMP NOT NULL,
86 sig_fpr INT4 NOT NULL, -- REFERENCES fingerprint
87 unique (source, version)
90 CREATE TABLE src_uploaders (
91 id SERIAL PRIMARY KEY,
92 source INT4 NOT NULL REFERENCES source,
93 maintainer INT4 NOT NULL REFERENCES maintainer
96 CREATE TABLE dsc_files (
97 id SERIAL PRIMARY KEY,
98 source INT4 NOT NULL, -- REFERENCES source,
99 file INT4 NOT NULL, -- RERENCES files
100 unique (source, file)
103 CREATE TABLE binaries (
104 id SERIAL PRIMARY KEY,
105 package TEXT NOT NULL,
106 version TEXT NOT NULL,
107 maintainer INT4 NOT NULL, -- REFERENCES maintainer
108 source INT4, -- REFERENCES source,
109 architecture INT4 NOT NULL, -- REFERENCES architecture
110 file INT4 UNIQUE NOT NULL, -- REFERENCES files,
112 -- joeyh@ doesn't want .udebs and .debs with the same name, which is why the unique () doesn't mention type
113 sig_fpr INT4 NOT NULL, -- REFERENCES fingerprint
114 unique (package, version, architecture)
118 id SERIAL PRIMARY KEY,
119 suite_name TEXT NOT NULL,
128 id SERIAL PRIMARY KEY,
129 queue_name TEXT NOT NULL
132 CREATE TABLE suite_architectures (
133 suite INT4 NOT NULL, -- REFERENCES suite
134 architecture INT4 NOT NULL, -- REFERENCES architecture
135 unique (suite, architecture)
138 CREATE TABLE bin_associations (
139 id SERIAL PRIMARY KEY,
140 suite INT4 NOT NULL, -- REFERENCES suite
141 bin INT4 NOT NULL, -- REFERENCES binaries
145 CREATE TABLE src_associations (
146 id SERIAL PRIMARY KEY,
147 suite INT4 NOT NULL, -- REFERENCES suite
148 source INT4 NOT NULL, -- REFERENCES source
149 unique (suite, source)
152 CREATE TABLE section (
153 id SERIAL PRIMARY KEY,
154 section TEXT UNIQUE NOT NULL
157 CREATE TABLE priority (
158 id SERIAL PRIMARY KEY,
159 priority TEXT UNIQUE NOT NULL,
160 level INT4 UNIQUE NOT NULL
163 CREATE TABLE override_type (
164 id SERIAL PRIMARY KEY,
165 type TEXT UNIQUE NOT NULL
168 CREATE TABLE override (
169 package TEXT NOT NULL,
170 suite INT4 NOT NULL, -- references suite
171 component INT4 NOT NULL, -- references component
172 priority INT4, -- references priority
173 section INT4 NOT NULL, -- references section
174 type INT4 NOT NULL, -- references override_type
176 unique (suite, component, package, type)
179 CREATE TABLE queue_build (
180 suite INT4 NOT NULL, -- references suite
181 queue INT4 NOT NULL, -- references queue
182 filename TEXT NOT NULL,
183 in_queue BOOLEAN NOT NULL,
189 CREATE INDEX bin_associations_bin ON bin_associations (bin);
190 CREATE INDEX src_associations_source ON src_associations (source);
191 CREATE INDEX source_maintainer ON source (maintainer);
192 CREATE INDEX binaries_maintainer ON binaries (maintainer);
193 CREATE INDEX binaries_fingerprint on binaries (sig_fpr);
194 CREATE INDEX source_fingerprint on source (sig_fpr);
195 CREATE INDEX dsc_files_file ON dsc_files (file);
198 CREATE FUNCTION space_concat(text, text) RETURNS text
200 WHEN $2 is null or $2 = '' THEN $1
201 WHEN $1 is null or $1 = '' THEN $2
206 CREATE AGGREGATE space_separated_list (
208 SFUNC = space_concat,