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