1 | -- fix group revision tables |
---|
2 | |
---|
3 | ALTER TABLE group_extra_revision |
---|
4 | DROP CONSTRAINT group_extra_revision_pkey; |
---|
5 | |
---|
6 | ALTER TABLE group_revision |
---|
7 | DROP CONSTRAINT group_revision_pkey; |
---|
8 | |
---|
9 | ALTER TABLE package_group_revision |
---|
10 | DROP CONSTRAINT package_group_revision_pkey; |
---|
11 | |
---|
12 | ALTER TABLE group_extra |
---|
13 | DROP CONSTRAINT group_extra_revision_fkey; |
---|
14 | |
---|
15 | ALTER TABLE group_extra_revision |
---|
16 | DROP CONSTRAINT group_extra_revision_continuity_id_fkey; |
---|
17 | |
---|
18 | ALTER TABLE group_revision |
---|
19 | DROP CONSTRAINT group_revision_name_key; |
---|
20 | |
---|
21 | ALTER TABLE package_group |
---|
22 | DROP CONSTRAINT package_group_package_id_fkey; |
---|
23 | |
---|
24 | ALTER TABLE package_group |
---|
25 | DROP CONSTRAINT package_group_revision_fkey; |
---|
26 | |
---|
27 | ALTER TABLE package_group_revision |
---|
28 | DROP CONSTRAINT package_group_revision_continuity_id_fkey; |
---|
29 | |
---|
30 | |
---|
31 | ALTER TABLE group_extra_revision |
---|
32 | ADD CONSTRAINT group_extra_revision_pkey PRIMARY KEY (id, revision_id); |
---|
33 | |
---|
34 | ALTER TABLE group_revision |
---|
35 | ADD CONSTRAINT group_revision_pkey PRIMARY KEY (id, revision_id); |
---|
36 | |
---|
37 | ALTER TABLE package_group_revision |
---|
38 | ADD CONSTRAINT package_group_revision_pkey PRIMARY KEY (id, revision_id); |
---|
39 | |
---|
40 | ALTER TABLE group_extra |
---|
41 | ADD CONSTRAINT group_extra_revision_id_fkey FOREIGN KEY (revision_id) REFERENCES revision(id); |
---|
42 | |
---|
43 | ALTER TABLE group_extra_revision |
---|
44 | ADD CONSTRAINT group_extra_revision_continuity_id_fkey FOREIGN KEY (continuity_id) REFERENCES group_extra(id); |
---|
45 | |
---|
46 | ALTER TABLE group_revision |
---|
47 | ADD CONSTRAINT group_revision_continuity_id_fkey FOREIGN KEY (continuity_id) REFERENCES "group"(id); |
---|
48 | |
---|
49 | |
---|
50 | ALTER TABLE package_group |
---|
51 | ADD CONSTRAINT package_group_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id); |
---|
52 | |
---|
53 | ALTER TABLE package_group |
---|
54 | ADD CONSTRAINT package_group_revision_id_fkey FOREIGN KEY (revision_id) REFERENCES revision(id); |
---|
55 | |
---|
56 | ALTER TABLE package_group_revision |
---|
57 | ADD CONSTRAINT package_group_revision_continuity_id_fkey FOREIGN KEY (continuity_id) REFERENCES package_group(id); |
---|
58 | |
---|
59 | |
---|
60 | -- add changemask table |
---|
61 | |
---|
62 | CREATE TABLE changemask ( |
---|
63 | ref text NOT NULL, |
---|
64 | timestamp timestamp without time zone |
---|
65 | ); |
---|
66 | |
---|
67 | ALTER TABLE changemask |
---|
68 | ADD CONSTRAINT changemask_pkey PRIMARY KEY (ref); |
---|
69 | |
---|
70 | -- fix defaults |
---|
71 | ALTER TABLE package |
---|
72 | ALTER COLUMN id DROP DEFAULT; |
---|
73 | |
---|
74 | ALTER TABLE package_extra |
---|
75 | ALTER COLUMN id DROP DEFAULT; |
---|
76 | |
---|
77 | ALTER TABLE package_extra_revision |
---|
78 | ALTER COLUMN id DROP DEFAULT; |
---|
79 | |
---|
80 | |
---|
81 | ALTER TABLE package_resource |
---|
82 | ALTER COLUMN id DROP DEFAULT; |
---|
83 | |
---|
84 | ALTER TABLE package_resource_revision |
---|
85 | ALTER COLUMN id DROP DEFAULT; |
---|
86 | |
---|
87 | ALTER TABLE package_revision |
---|
88 | ALTER COLUMN id DROP DEFAULT; |
---|
89 | |
---|
90 | ALTER TABLE package_tag |
---|
91 | ALTER COLUMN id DROP DEFAULT; |
---|
92 | |
---|
93 | ALTER TABLE package_tag_revision |
---|
94 | ALTER COLUMN id DROP DEFAULT; |
---|
95 | |
---|
96 | ALTER TABLE revision |
---|
97 | ALTER COLUMN id DROP DEFAULT; |
---|
98 | |
---|
99 | ALTER TABLE tag |
---|
100 | ALTER COLUMN id DROP DEFAULT; |
---|
101 | |
---|
102 | DROP SEQUENCE package_extra_id_seq; |
---|
103 | |
---|
104 | DROP SEQUENCE package_extra_revision_id_seq; |
---|
105 | |
---|
106 | DROP SEQUENCE package_id_seq; |
---|
107 | |
---|
108 | DROP SEQUENCE package_resource_id_seq; |
---|
109 | |
---|
110 | DROP SEQUENCE package_resource_revision_id_seq; |
---|
111 | |
---|
112 | DROP SEQUENCE package_revision_id_seq; |
---|
113 | |
---|
114 | DROP SEQUENCE package_tag_id_seq; |
---|
115 | |
---|
116 | DROP SEQUENCE package_tag_revision_id_seq; |
---|
117 | |
---|
118 | DROP SEQUENCE revision_id_seq; |
---|
119 | |
---|
120 | DROP SEQUENCE tag_id_seq; |
---|
121 | |
---|
122 | |
---|
123 | -- fix licence id |
---|
124 | |
---|
125 | ALTER TABLE package |
---|
126 | ALTER COLUMN license_id TYPE text /* TYPE change - table: package original: character varying(100) new: text */; |
---|
127 | |
---|
128 | ALTER TABLE package_revision |
---|
129 | ALTER COLUMN license_id TYPE text /* TYPE change - table: package_revision original: character varying(100) new: text */; |
---|
130 | |
---|
131 | |
---|
132 | -- drop download_url |
---|
133 | |
---|
134 | ALTER TABLE package_revision |
---|
135 | DROP COLUMN download_url; |
---|
136 | |
---|
137 | -- fix changeset |
---|
138 | |
---|
139 | ALTER TABLE changeset |
---|
140 | DROP COLUMN status; |
---|
141 | |
---|
142 | -- fix not null |
---|
143 | |
---|
144 | ALTER TABLE package_group_revision |
---|
145 | ALTER COLUMN revision_id SET NOT NULL; |
---|
146 | |
---|
147 | ALTER TABLE group_extra_revision |
---|
148 | ALTER COLUMN revision_id SET NOT NULL; |
---|
149 | |
---|
150 | ALTER TABLE group_revision |
---|
151 | ALTER COLUMN revision_id SET NOT NULL; |
---|
152 | |
---|
153 | ALTER TABLE harvesting_job |
---|
154 | ALTER COLUMN status SET NOT NULL; |
---|
155 | |
---|
156 | -- add unique contraints |
---|
157 | |
---|
158 | ALTER TABLE tag |
---|
159 | ADD CONSTRAINT tag_name_key UNIQUE (name); |
---|
160 | |
---|
161 | ALTER TABLE package |
---|
162 | ADD CONSTRAINT package_name_key UNIQUE (name); |
---|
163 | |
---|
164 | |
---|
165 | -- fix on update cascades |
---|
166 | |
---|
167 | ALTER TABLE package |
---|
168 | DROP CONSTRAINT package_revision_id_fkey; |
---|
169 | |
---|
170 | ALTER TABLE package_extra |
---|
171 | DROP CONSTRAINT package_extra_package_id_fkey; |
---|
172 | |
---|
173 | ALTER TABLE package_extra |
---|
174 | DROP CONSTRAINT package_extra_revision_id_fkey; |
---|
175 | |
---|
176 | ALTER TABLE package_extra_revision |
---|
177 | DROP CONSTRAINT package_extra_revision_continuity_id_fkey; |
---|
178 | |
---|
179 | ALTER TABLE package_extra_revision |
---|
180 | DROP CONSTRAINT package_extra_revision_package_id_fkey; |
---|
181 | |
---|
182 | ALTER TABLE package_extra_revision |
---|
183 | DROP CONSTRAINT package_extra_revision_revision_id_fkey; |
---|
184 | |
---|
185 | ALTER TABLE package_resource |
---|
186 | DROP CONSTRAINT package_resource_package_id_fkey; |
---|
187 | |
---|
188 | ALTER TABLE package_resource_revision |
---|
189 | DROP CONSTRAINT package_resource_revision_continuity_id_fkey; |
---|
190 | |
---|
191 | ALTER TABLE package_resource_revision |
---|
192 | DROP CONSTRAINT package_resource_revision_package_id_fkey; |
---|
193 | |
---|
194 | ALTER TABLE package_revision |
---|
195 | DROP CONSTRAINT package_revision_continuity_id_fkey; |
---|
196 | |
---|
197 | ALTER TABLE package_revision |
---|
198 | DROP CONSTRAINT package_revision_revision_id_fkey; |
---|
199 | |
---|
200 | ALTER TABLE package_role |
---|
201 | DROP CONSTRAINT package_role_package_id_fkey; |
---|
202 | |
---|
203 | ALTER TABLE package_search |
---|
204 | DROP CONSTRAINT package_search_package_id_fkey; |
---|
205 | |
---|
206 | ALTER TABLE package_tag |
---|
207 | DROP CONSTRAINT package_tag_package_id_fkey; |
---|
208 | |
---|
209 | ALTER TABLE package_tag |
---|
210 | DROP CONSTRAINT package_tag_revision_id_fkey; |
---|
211 | |
---|
212 | ALTER TABLE package_tag |
---|
213 | DROP CONSTRAINT package_tag_tag_id_fkey; |
---|
214 | |
---|
215 | ALTER TABLE package_tag_revision |
---|
216 | DROP CONSTRAINT package_tag_revision_continuity_id_fkey; |
---|
217 | |
---|
218 | ALTER TABLE package_tag_revision |
---|
219 | DROP CONSTRAINT package_tag_revision_package_id_fkey; |
---|
220 | |
---|
221 | ALTER TABLE package_tag_revision |
---|
222 | DROP CONSTRAINT package_tag_revision_revision_id_fkey; |
---|
223 | |
---|
224 | ALTER TABLE package_tag_revision |
---|
225 | DROP CONSTRAINT package_tag_revision_tag_id_fkey; |
---|
226 | |
---|
227 | ALTER TABLE rating |
---|
228 | DROP CONSTRAINT rating_package_id_fkey; |
---|
229 | |
---|
230 | |
---|
231 | ALTER TABLE package |
---|
232 | ADD CONSTRAINT package_revision_id_fkey FOREIGN KEY (revision_id) REFERENCES revision(id); |
---|
233 | |
---|
234 | ALTER TABLE package_extra |
---|
235 | ADD CONSTRAINT package_extra_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id); |
---|
236 | |
---|
237 | ALTER TABLE package_extra |
---|
238 | ADD CONSTRAINT package_extra_revision_id_fkey FOREIGN KEY (revision_id) REFERENCES revision(id); |
---|
239 | |
---|
240 | ALTER TABLE package_extra_revision |
---|
241 | ADD CONSTRAINT package_extra_revision_continuity_id_fkey FOREIGN KEY (continuity_id) REFERENCES package_extra(id); |
---|
242 | |
---|
243 | ALTER TABLE package_extra_revision |
---|
244 | ADD CONSTRAINT package_extra_revision_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id); |
---|
245 | |
---|
246 | ALTER TABLE package_extra_revision |
---|
247 | ADD CONSTRAINT package_extra_revision_revision_id_fkey FOREIGN KEY (revision_id) REFERENCES revision(id); |
---|
248 | |
---|
249 | |
---|
250 | ALTER TABLE package_resource |
---|
251 | ADD CONSTRAINT package_resource_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id); |
---|
252 | |
---|
253 | ALTER TABLE package_resource_revision |
---|
254 | ADD CONSTRAINT package_resource_revision_continuity_id_fkey FOREIGN KEY (continuity_id) REFERENCES package_resource(id); |
---|
255 | |
---|
256 | ALTER TABLE package_resource_revision |
---|
257 | ADD CONSTRAINT package_resource_revision_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id); |
---|
258 | |
---|
259 | ALTER TABLE package_revision |
---|
260 | ADD CONSTRAINT package_revision_continuity_id_fkey FOREIGN KEY (continuity_id) REFERENCES package(id); |
---|
261 | |
---|
262 | ALTER TABLE package_revision |
---|
263 | ADD CONSTRAINT package_revision_revision_id_fkey FOREIGN KEY (revision_id) REFERENCES revision(id); |
---|
264 | |
---|
265 | ALTER TABLE package_role |
---|
266 | ADD CONSTRAINT package_role_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id); |
---|
267 | |
---|
268 | ALTER TABLE package_search |
---|
269 | ADD CONSTRAINT package_search_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id); |
---|
270 | |
---|
271 | ALTER TABLE package_tag |
---|
272 | ADD CONSTRAINT package_tag_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id); |
---|
273 | |
---|
274 | ALTER TABLE package_tag |
---|
275 | ADD CONSTRAINT package_tag_revision_id_fkey FOREIGN KEY (revision_id) REFERENCES revision(id); |
---|
276 | |
---|
277 | ALTER TABLE package_tag |
---|
278 | ADD CONSTRAINT package_tag_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES tag(id); |
---|
279 | |
---|
280 | ALTER TABLE package_tag_revision |
---|
281 | ADD CONSTRAINT package_tag_revision_continuity_id_fkey FOREIGN KEY (continuity_id) REFERENCES package_tag(id); |
---|
282 | |
---|
283 | ALTER TABLE package_tag_revision |
---|
284 | ADD CONSTRAINT package_tag_revision_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id); |
---|
285 | |
---|
286 | ALTER TABLE package_tag_revision |
---|
287 | ADD CONSTRAINT package_tag_revision_revision_id_fkey FOREIGN KEY (revision_id) REFERENCES revision(id); |
---|
288 | |
---|
289 | ALTER TABLE package_tag_revision |
---|
290 | ADD CONSTRAINT package_tag_revision_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES tag(id); |
---|
291 | |
---|
292 | ALTER TABLE rating |
---|
293 | ADD CONSTRAINT rating_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id); |
---|
294 | |
---|