]> git.decadent.org.uk Git - dak.git/blob - init_pool.sql
add fingerprints and install date (source).
[dak.git] / init_pool.sql
1 DROP DATABASE projectb;
2 CREATE DATABASE projectb;
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 fingerprint (
32        id SERIAL PRIMARY KEY,
33        fingerprint TEXT UNIQUE NOT NULL
34 );
35
36 CREATE TABLE location (
37        id SERIAL PRIMARY KEY,
38        path TEXT NOT NULL,
39        component INT4 REFERENCES component,
40        archive INT4 REFERENCES archive,
41        type TEXT NOT NULL
42 );
43
44 -- No references below here to allow sane population; added post-population
45
46 CREATE TABLE files (
47        id SERIAL PRIMARY KEY,
48        filename TEXT NOT NULL,
49        size INT8 NOT NULL,
50        md5sum TEXT NOT NULL,
51        location INT4 NOT NULL, -- REFERENCES location
52        last_used TIMESTAMP,
53        unique (filename, location)
54 );
55
56 CREATE TABLE source (
57         id SERIAL PRIMARY KEY,
58         source TEXT NOT NULL,
59         version TEXT NOT NULL,
60         maintainer INT4 NOT NULL, -- REFERENCES maintainer
61         file INT4 UNIQUE NOT NULL, -- REFERENCES files
62         install_date TIMESTAMP NOT NULL,
63         sig_fpr INT4 NOT NULL, -- REFERENCES fingerprint
64         unique (source, version)
65 );
66
67 CREATE TABLE dsc_files (
68        id SERIAL PRIMARY KEY,
69        source INT4 NOT NULL, -- REFERENCES source,
70        file INT4 NOT NULL, -- RERENCES files
71        unique (source, file)
72 );
73
74 CREATE TABLE binaries (
75        id SERIAL PRIMARY KEY,
76        package TEXT NOT NULL,
77        version TEXT NOT NULL,
78        maintainer INT4 NOT NULL, -- REFERENCES maintainer
79        source INT4, -- REFERENCES source,
80        architecture INT4 NOT NULL, -- REFERENCES architecture
81        file INT4 UNIQUE NOT NULL, -- REFERENCES files,
82        type TEXT NOT NULL,
83 -- joeyh@ doesn't want .udebs and .debs with the same name, which is why the unique () doesn't mention type
84        sig_fpr INT4 NOT NULL, -- REFERENCES fingerprint
85        unique (package, version, architecture)
86 );
87
88 CREATE TABLE suite (
89        id SERIAL PRIMARY KEY,
90        suite_name TEXT NOT NULL,
91        version TEXT,
92        origin TEXT,
93        label TEXT,
94        policy_engine TEXT,
95        description TEXT
96 );
97
98 CREATE TABLE suite_architectures (
99        suite INT4 NOT NULL, -- REFERENCES suite
100        architecture INT4 NOT NULL, -- REFERENCES architecture
101        unique (suite, architecture)
102 );
103
104 CREATE TABLE bin_associations (
105        id SERIAL PRIMARY KEY,
106        suite INT4 NOT NULL, -- REFERENCES suite
107        bin INT4 NOT NULL, -- REFERENCES binaries
108        unique (suite, bin)
109 );
110
111 CREATE TABLE src_associations (
112        id SERIAL PRIMARY KEY,
113        suite INT4 NOT NULL, -- REFERENCES suite
114        source INT4 NOT NULL, -- REFERENCES source
115        unique (suite, source)
116 );
117
118 CREATE TABLE section (
119        id SERIAL PRIMARY KEY,
120        section TEXT UNIQUE NOT NULL
121 );
122
123 CREATE TABLE priority (
124        id SERIAL PRIMARY KEY,
125        priority TEXT UNIQUE NOT NULL,
126        level INT4 UNIQUE NOT NULL
127 );
128
129 CREATE TABLE override_type (
130        id SERIAL PRIMARY KEY,
131        type TEXT UNIQUE NOT NULL
132 );
133
134 CREATE TABLE override (
135        package TEXT NOT NULL,
136        suite INT4 NOT NULL, -- references suite
137        component INT4 NOT NULL, -- references component
138        priority INT4, -- references priority
139        section INT4 NOT NULL, -- references section
140        type INT4 NOT NULL, -- references override_type
141        maintainer TEXT,
142        unique (suite, component, package, type)
143 );
144
145 -- Critical indexes
146
147 CREATE INDEX bin_associations_bin ON bin_associations (bin);
148 CREATE INDEX src_associations_source ON src_associations (source);
149 CREATE INDEX source_maintainer ON source (maintainer);
150 CREATE INDEX binaries_maintainer ON binaries (maintainer);
151 CREATE INDEX dsc_files_file ON dsc_files (file);