]> git.decadent.org.uk Git - dak.git/blob - setup/init_pool.sql
[??] sync with ftp-master/dak master
[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 src_uploaders (
32        id SERIAL PRIMARY KEY,
33        source INT4 NOT NULL REFERENCES source,
34        maintainer INT4 NOT NULL REFERENCES maintainer
35 );
36
37 CREATE TABLE uid (
38        id SERIAL PRIMARY KEY,
39        uid TEXT UNIQUE NOT NULL,
40        name TEXT
41 );
42
43 CREATE TABLE keyrings (
44        id SERIAL PRIMARY KEY,
45        name TEXT
46 );
47
48
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
54 );
55
56 CREATE TABLE location (
57        id SERIAL PRIMARY KEY,
58        path TEXT NOT NULL,
59        component INT4 REFERENCES component,
60        archive INT4 REFERENCES archive,
61        type TEXT NOT NULL
62 );
63
64 -- No references below here to allow sane population; added post-population
65
66 CREATE TABLE files (
67        id SERIAL PRIMARY KEY,
68        filename TEXT NOT NULL,
69        size INT8 NOT NULL,
70        md5sum TEXT NOT NULL,
71        location INT4 NOT NULL, -- REFERENCES location
72        last_used TIMESTAMP,
73        unique (filename, location)
74 );
75
76 CREATE TABLE source (
77         id SERIAL PRIMARY KEY,
78         source TEXT NOT NULL,
79         version TEXT NOT NULL,
80         maintainer INT4 NOT NULL, -- REFERENCES maintainer
81         file INT4 UNIQUE NOT NULL, -- REFERENCES files
82         install_date TIMESTAMP NOT NULL,
83         sig_fpr INT4 NOT NULL, -- REFERENCES fingerprint
84         unique (source, version)
85 );
86
87 CREATE TABLE dsc_files (
88        id SERIAL PRIMARY KEY,
89        source INT4 NOT NULL, -- REFERENCES source,
90        file INT4 NOT NULL, -- RERENCES files
91        unique (source, file)
92 );
93
94 CREATE TABLE binaries (
95        id SERIAL PRIMARY KEY,
96        package TEXT NOT NULL,
97        version TEXT NOT NULL,
98        maintainer INT4 NOT NULL, -- REFERENCES maintainer
99        source INT4, -- REFERENCES source,
100        architecture INT4 NOT NULL, -- REFERENCES architecture
101        file INT4 UNIQUE NOT NULL, -- REFERENCES files,
102        type TEXT NOT NULL,
103 -- joeyh@ doesn't want .udebs and .debs with the same name, which is why the unique () doesn't mention type
104        sig_fpr INT4 NOT NULL, -- REFERENCES fingerprint
105        unique (package, version, architecture)
106 );
107
108 CREATE TABLE suite (
109        id SERIAL PRIMARY KEY,
110        suite_name TEXT NOT NULL,
111        version TEXT,
112        origin TEXT,
113        label TEXT,
114        policy_engine TEXT,
115        description TEXT
116 );
117
118 CREATE TABLE queue (
119        id SERIAL PRIMARY KEY,
120        queue_name TEXT NOT NULL
121 );
122
123 CREATE TABLE suite_architectures (
124        suite INT4 NOT NULL, -- REFERENCES suite
125        architecture INT4 NOT NULL, -- REFERENCES architecture
126        unique (suite, architecture)
127 );
128
129 CREATE TABLE bin_associations (
130        id SERIAL PRIMARY KEY,
131        suite INT4 NOT NULL, -- REFERENCES suite
132        bin INT4 NOT NULL, -- REFERENCES binaries
133        unique (suite, bin)
134 );
135
136 CREATE TABLE src_associations (
137        id SERIAL PRIMARY KEY,
138        suite INT4 NOT NULL, -- REFERENCES suite
139        source INT4 NOT NULL, -- REFERENCES source
140        unique (suite, source)
141 );
142
143 CREATE TABLE section (
144        id SERIAL PRIMARY KEY,
145        section TEXT UNIQUE NOT NULL
146 );
147
148 CREATE TABLE priority (
149        id SERIAL PRIMARY KEY,
150        priority TEXT UNIQUE NOT NULL,
151        level INT4 UNIQUE NOT NULL
152 );
153
154 CREATE TABLE override_type (
155        id SERIAL PRIMARY KEY,
156        type TEXT UNIQUE NOT NULL
157 );
158
159 CREATE TABLE override (
160        package TEXT NOT NULL,
161        suite INT4 NOT NULL, -- references suite
162        component INT4 NOT NULL, -- references component
163        priority INT4, -- references priority
164        section INT4 NOT NULL, -- references section
165        type INT4 NOT NULL, -- references override_type
166        maintainer TEXT,
167        unique (suite, component, package, type)
168 );
169
170 CREATE TABLE queue_build (
171        suite INT4 NOT NULL, -- references suite
172        queue INT4 NOT NULL, -- references queue
173        filename TEXT NOT NULL,
174        in_queue BOOLEAN NOT NULL,
175        last_used TIMESTAMP
176 );
177
178 -- Critical indexes
179
180 CREATE INDEX bin_associations_bin ON bin_associations (bin);
181 CREATE INDEX src_associations_source ON src_associations (source);
182 CREATE INDEX source_maintainer ON source (maintainer);
183 CREATE INDEX binaries_maintainer ON binaries (maintainer);
184 CREATE INDEX binaries_fingerprint on binaries (sig_fpr);
185 CREATE INDEX source_fingerprint on source (sig_fpr);
186 CREATE INDEX dsc_files_file ON dsc_files (file);